3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php // initial position var_dump(preg_match('#/search/(?P<mac>(?:[[:xdigit:]]{2}([-:]))(?:[[:xdigit:]]{2}\2){4}[[:xdigit:]]{2})#', '/search/12-12-12-12-12-12', $matches)); var_dump($matches); // named subpattern //var_dump(preg_match('#/search/(?P<mac>(?:[[:xdigit:]]{2}(?P<sep>[-:]))(?:[[:xdigit:]]{2}(?P=sep)){4}[[:xdigit:]]{2})#', '/search/12-12-12-12-12-12', $matches)); //var_dump($matches); // impossible to fix in general var_dump(preg_match('#/(?P<id>\d+)/(?P<mac>(?:[[:xdigit:]]{2}([-:]))(?:[[:xdigit:]]{2}\3){4}[[:xdigit:]]{2})#', '/555/12-12-12-12-12-12', $matches)); var_dump($matches); //fix var_dump(preg_match('#((?:[[:xdigit:]]{2}([-:]))(?:[[:xdigit:]]{2}\2){4}[[:xdigit:]]{2})#', '12-12-12-12-12-12', $matches)); var_dump($matches); // problem //var_dump(preg_match('#(?:[[:xdigit:]]{2}([-:]))(?:[[:xdigit:]]{2}\2){4}[[:xdigit:]]{2}#', '12-12-12-12-12-12', $matches)); //var_dump($matches);
Output for 4.3.3 - 5.0.5, 5.1.1 - 7.1.0
int(1) array(4) { [0]=> string(25) "/search/12-12-12-12-12-12" ["mac"]=> string(17) "12-12-12-12-12-12" [1]=> string(17) "12-12-12-12-12-12" [2]=> string(1) "-" } int(1) array(6) { [0]=> string(22) "/555/12-12-12-12-12-12" ["id"]=> string(3) "555" [1]=> string(3) "555" ["mac"]=> string(17) "12-12-12-12-12-12" [2]=> string(17) "12-12-12-12-12-12" [3]=> string(1) "-" } int(1) array(3) { [0]=> string(17) "12-12-12-12-12-12" [1]=> string(17) "12-12-12-12-12-12" [2]=> string(1) "-" }
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/USrJ8 on line 24
Process exited with code 255.
Output for 4.3.0 - 4.3.2
int(1) array(3) { [0]=> string(25) "/search/12-12-12-12-12-12" [1]=> string(17) "12-12-12-12-12-12" [2]=> string(1) "-" } int(1) array(4) { [0]=> string(22) "/555/12-12-12-12-12-12" [1]=> string(3) "555" [2]=> string(17) "12-12-12-12-12-12" [3]=> string(1) "-" } int(1) array(3) { [0]=> string(17) "12-12-12-12-12-12" [1]=> string(17) "12-12-12-12-12-12" [2]=> string(1) "-" }