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.32, 8.3.0 - 8.3.32, 8.4.1 - 8.4.23, 8.5.0 - 8.5.8
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:
102.62 ms | 1332 KiB | 4 Q