rest_validate_json_schema_pattern

The timeline below displays how wordpress function rest_validate_json_schema_pattern has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.6

/**
 * Validates if the JSON Schema pattern matches a value.
 *
 * @since 5.6.0
 *
 * @param string $pattern The pattern to match against.
 * @param string $value   The value to check.
 * @return bool           True if the pattern matches the given value, false otherwise.
 */
function rest_validate_json_schema_pattern($pattern, $value)
{
    $escaped_pattern = str_replace('#', '\#', $pattern);
    return 1 === preg_match('#' . $escaped_pattern . '#u', $value);
}