3v4l.org

run code in 300+ PHP versions simultaneously
<?php $regular_expression = '/wp/v2/templates/(?P<parent>([^\/:<>\*\?"\|]+(?:\/[^\/:<>\*\?"\|]+)?)[\/\w%-]+)/revisions'; $current_rest_ednpoints_route_pattern = '@^' . $regular_expression . '$@i'; $request_uri = '/wp/v2/templates/my_theme_name//my_template_id/revisions'; echo 'Current regular expression: ' . $regular_expression . PHP_EOL . PHP_EOL; echo 1 === preg_match($current_rest_ednpoints_route_pattern, $request_uri) ? 'Matches "my_theme_name/my_template_id" IDs as expected.' : 'Doesn\'t match "my_theme_name/my_template_id" IDs. This is NOT expected.' ; echo PHP_EOL; $request_uri = '/wp/v2/templates/my_template_id/revisions'; echo 1 === preg_match($current_rest_ednpoints_route_pattern, $request_uri) ? 'Matches "my_template_id" IDs. This is NOT expected.' : 'Doesn\'t match "my_template_id" IDs as expected.' ; echo PHP_EOL . PHP_EOL; $fixed_regular_expression = '/wp/v2/templates/(?P<parent>([^\/:<>\*\?"\|]+\/\/?[^\/:<>\*\?"\|]+)[\/\w%-]+)/revisions'; $current_rest_ednpoints_route_pattern = '@^' . $fixed_regular_expression . '$@i'; $request_uri = '/wp/v2/templates/my_theme_name//my_template_id/revisions'; echo 'Fixed regular expression: ' . $fixed_regular_expression . PHP_EOL . PHP_EOL; echo 1 === preg_match($current_rest_ednpoints_route_pattern, $request_uri) ? 'Matches "my_theme_name/my_template_id" IDs as expected.' : 'Doesn\'t match "my_theme_name/my_template_id" IDs. This is NOT expected.' ; echo PHP_EOL; $request_uri = '/wp/v2/templates/my_template_id/revisions'; echo 1 === preg_match($current_rest_ednpoints_route_pattern, $request_uri) ? 'Matches "my_template_id" IDs. This is NOT expected.' : 'Doesn\'t match "my_template_id" IDs as expected.' ; echo PHP_EOL . PHP_EOL;

preferences:
26.28 ms | 404 KiB | 5 Q