3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $string = "lorem ipsum <foo=42> dolor sit <bar=[17]> amet consectepture <foo=[37]> adipisicing elit <bar=19> sed do eiusmod"; $re = '/(?J)<%{name}=(?(?P<value>\\d+)|\\[(?P<value>\\d+)\\])>/'; foreach (array("foo", "bar") as $name) { echo $name, ": "; if (false !== preg_match(str_replace("%{name}", $name, $re), $string, $m)) { var_dump($m['value']); } else { echo "<FALSE>\n"; } }
Output for 4.4.5 - 4.4.9, 5.2.0 - 5.6.28, 7.0.0 - 7.1.0
foo: Warning: preg_match(): Compilation failed: assertion expected after (?( at offset 12 in /in/In7Yu on line 8 <FALSE> bar: Warning: preg_match(): Compilation failed: assertion expected after (?( at offset 12 in /in/In7Yu on line 8 <FALSE>
Output for hhvm-3.10.0 - 3.13.2
foo: Warning: Compilation failed: assertion expected after (?( or (?(?C) at offset 12 in /in/In7Yu on line 8 <FALSE> bar: Warning: Compilation failed: assertion expected after (?( or (?(?C) at offset 12 in /in/In7Yu on line 8 <FALSE>
Output for 4.3.11 - 4.4.4, 5.0.0 - 5.1.6
foo: Warning: preg_match(): Compilation failed: unrecognized character after (? at offset 2 in /in/In7Yu on line 8 <FALSE> bar: Warning: preg_match(): Compilation failed: unrecognized character after (? at offset 2 in /in/In7Yu on line 8 <FALSE>
Output for 4.3.0 - 4.3.10
foo: Warning: Compilation failed: unrecognized character after (? at offset 2 in /in/In7Yu on line 8 <FALSE> bar: Warning: Compilation failed: unrecognized character after (? at offset 2 in /in/In7Yu on line 8 <FALSE>