No need for lookahead: just make preg_split capture delimiters as well (with PREG_SPLIT_DELIM_CAPTURE
option):
$str = 'Hello? My name is Ben! @ My age is 32.';
$arr = preg_split('/(\W)/', $str, null,
PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
Demo. With this setup, each \W
(non-word) symbol is captured separately (as a delimiter), but all \w
symbols are gathered into sequences (as parts of the string separated by \W
).