3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php preg_match_all('/(?J)(?<string>.*)1|(?<string>.*)2|(?<string>.*)3$/', "text2\npext3", $matches, PREG_SET_ORDER); var_dump($matches); preg_match_all('/(?J)(?<string>.*)1|(?<string>.*)2|(?<string>.*)3$/', "text2\npext3", $matches); var_dump($matches);
based on j8lJr
Output for 4.4.6 - 4.4.9, 5.2.2 - 5.6.30, hhvm-3.10.1 - 3.22.0, 7.0.0 - 7.2.6
array(2) { [0]=> array(4) { [0]=> string(5) "text2" ["string"]=> string(4) "text" [1]=> string(0) "" [2]=> string(4) "text" } [1]=> array(5) { [0]=> string(5) "pext3" ["string"]=> string(4) "pext" [1]=> string(0) "" [2]=> string(0) "" [3]=> string(4) "pext" } } array(5) { [0]=> array(2) { [0]=> string(5) "text2" [1]=> string(5) "pext3" } ["string"]=> array(2) { [0]=> string(0) "" [1]=> string(4) "pext" } [1]=> array(2) { [0]=> string(0) "" [1]=> string(0) "" } [2]=> array(2) { [0]=> string(4) "text" [1]=> string(0) "" } [3]=> array(2) { [0]=> string(0) "" [1]=> string(4) "pext" } }
Output for 5.2.0 - 5.2.1
Warning: preg_match_all(): Compilation failed: unrecognized character after (?< at offset 7 in /in/fnm76 on line 5 NULL Warning: preg_match_all(): Compilation failed: unrecognized character after (?< at offset 7 in /in/fnm76 on line 8 NULL
Output for 4.3.11 - 4.4.4, 5.0.0 - 5.1.6
Warning: preg_match_all(): Compilation failed: unrecognized character after (? at offset 2 in /in/fnm76 on line 5 array(0) { } Warning: preg_match_all(): Compilation failed: unrecognized character after (? at offset 2 in /in/fnm76 on line 8 array(0) { }
Output for 4.4.5
Warning: preg_match_all(): Compilation failed: unrecognized character after (?< at offset 7 in /in/fnm76 on line 5 array(0) { } Warning: preg_match_all(): Compilation failed: unrecognized character after (?< at offset 7 in /in/fnm76 on line 8 array(0) { }
Output for 4.3.0 - 4.3.10
Warning: Compilation failed: unrecognized character after (? at offset 2 in /in/fnm76 on line 5 array(0) { } Warning: Compilation failed: unrecognized character after (? at offset 2 in /in/fnm76 on line 8 array(0) { }