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]+'; preg_match_all("/([-+])?($ATOM_REGEX:)?($ATOM_REGEX)/", $query, $match); print_r($match);
Output for 4.3.0 - 7.1.0
Array ( [0] => Array ( [0] => -exclude [1] => -"exclude phrase" [2] => "phrase 1" [3] => keyword [4] => +k:v [5] => -k2:v2 [6] => +"q kw":2 ) [1] => Array ( [0] => - [1] => - [2] => [3] => [4] => + [5] => - [6] => + ) [2] => Array ( [0] => [1] => [2] => [3] => [4] => k: [5] => k2: [6] => "q kw" ) [3] => Array ( [0] => exclude [1] => "exclude phrase" [2] => "phrase 1" [3] => keyword [4] => v [5] => v2 [6] => :2 ) )