3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = '43_this_2 is test'; preg_match('/(?P<test>\w+)/', $string, $matches); // basic syntax var_dump($matches['test']); preg_match('/(?<test>.+)/', $string, $matches); // alternative var_dump($matches['test']); preg_match("/(?'test'.+)/", $string, $matches); // alternative var_dump($matches['test']); echo preg_replace('/\{(\w+)\}/', '(?<\1>\w+)', '/users/{user}/photos/{photo}');

preferences:
29.1 ms | 402 KiB | 5 Q