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.


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


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


Since 5.6.0 Introduced.

Code of rest_validate_json_schema_pattern() WP 5.7.2

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

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