PHP regular expression to match words
If you just want to add an asterisk after each "word" you could do this:
<?php
$test = 'one "two" (three) -four-';
echo preg_replace('/(\w+)/', "$1*", $test);
?>
http://phpfiddle.org/main/code/8nr-bpb
You can use a negative lookahead to split on word boundaries, like this:
$array = preg_split( '/(?!\w)\b/', 'one "two" (three) -four-');
A print_r( $array);
gives you the exact output desired:
Array ( [0] => one [1] => "two [2] => " (three [3] => ) -four [4] => - )