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;
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Current regular expression: /wp/v2/templates/(?P<parent>([^\/:<>\*\?"\|]+(?:\/[^\/:<>\*\?"\|]+)?)[\/\w%-]+)/revisions Matches "my_theme_name/my_template_id" IDs as expected. Matches "my_template_id" IDs. This is NOT expected. Fixed regular expression: /wp/v2/templates/(?P<parent>([^\/:<>\*\?"\|]+\/\/?[^\/:<>\*\?"\|]+)[\/\w%-]+)/revisions Matches "my_theme_name/my_template_id" IDs as expected. Doesn't match "my_template_id" IDs as expected.

preferences:
117.93 ms | 403 KiB | 91 Q