I have this string in $s:
$s
ben say (#yellow) hey
At the moment I\'m using:
$parts = array_filter(preg_sp
You could split it by Lookahead and Lookbehind Zero-Width Assertions:
Lookahead and Lookbehind Zero-Width Assertions
$parts = array_filter(preg_split('/\s+|(?=[()])|(?<=[()])/', $s));