WordPress at a glance
function is not described

rest_validate_json_schema_pattern() WP 5.6.0

Validates if the JSON Schema pattern matches a value.

No Hooks.

Return

true|false. True if the pattern matches the given value, false otherwise.

Usage

rest_validate_json_schema_pattern( $pattern, $value );
$pattern(string) (required)
The pattern to match against.
$value(string) (required)
The value to check.

Changelog

Since 5.6.0 Introduced.

Code of rest_validate_json_schema_pattern() WP 5.7.2

<?php
function rest_validate_json_schema_pattern( $pattern, $value ) {
	$escaped_pattern = str_replace( '#', '\\#', $pattern );

	return 1 === preg_match( '#' . $escaped_pattern . '#u', $value );
}