3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $query = "-exclude -\"exclude phrase\" \"phrase 1\" keyword +k:v -k2:v2 +\"q kw\":2"; $ATOM_REGEX = '"[^"]+"|[^"\s]+'; "?> atomic group"; preg_match_all("/(?>(?P<flag>[-+])?((?P<key>$ATOM_REGEX):)?(?P<value>$ATOM_REGEX))/", $query, $match, PREG_SET_ORDER); print_r($match);
Output for 4.3.3 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
Array ( [0] => Array ( [0] => -exclude [flag] => - [1] => - [2] => [key] => [3] => [value] => exclude [4] => exclude ) [1] => Array ( [0] => -"exclude phrase" [flag] => - [1] => - [2] => [key] => [3] => [value] => "exclude phrase" [4] => "exclude phrase" ) [2] => Array ( [0] => "phrase 1" [flag] => [1] => [2] => [key] => [3] => [value] => "phrase 1" [4] => "phrase 1" ) [3] => Array ( [0] => keyword [flag] => [1] => [2] => [key] => [3] => [value] => keyword [4] => keyword ) [4] => Array ( [0] => +k:v [flag] => + [1] => + [2] => k: [key] => k [3] => k [value] => v [4] => v ) [5] => Array ( [0] => -k2:v2 [flag] => - [1] => - [2] => k2: [key] => k2 [3] => k2 [value] => v2 [4] => v2 ) [6] => Array ( [0] => +"q kw":2 [flag] => + [1] => + [2] => "q kw": [key] => "q kw" [3] => "q kw" [value] => 2 [4] => 2 ) )
Output for hhvm-3.10.0

Process exited with code 153.
Output for 4.3.0 - 4.3.2
Array ( [0] => Array ( [0] => -exclude [1] => - [2] => [3] => [4] => exclude ) [1] => Array ( [0] => -"exclude phrase" [1] => - [2] => [3] => [4] => "exclude phrase" ) [2] => Array ( [0] => "phrase 1" [1] => [2] => [3] => [4] => "phrase 1" ) [3] => Array ( [0] => keyword [1] => [2] => [3] => [4] => keyword ) [4] => Array ( [0] => +k:v [1] => + [2] => k: [3] => k [4] => v ) [5] => Array ( [0] => -k2:v2 [1] => - [2] => k2: [3] => k2 [4] => v2 ) [6] => Array ( [0] => +"q kw":2 [1] => + [2] => "q kw": [3] => "q kw" [4] => 2 ) )