3v4l.org

run code in 500+ PHP versions simultaneously
<?php $re = '/(?:[^\s()":]*:)?"[^"]+"|[^\s()]+|[()]/m'; $str = '+test +word any -sampe (+toto +titi "generic test") -column:"test this" (+data id:1234)'; preg_match_all($re, $str, $matches); print_r($matches[0]);
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.21, 8.5.0 - 8.5.7
Array ( [0] => +test [1] => +word [2] => any [3] => -sampe [4] => ( [5] => +toto [6] => +titi [7] => "generic test" [8] => ) [9] => -column:"test this" [10] => ( [11] => +data [12] => id:1234 [13] => ) )

preferences:
92.46 ms | 1302 KiB | 4 Q