What you are trying to match can easily be done using array and string functions.
$parts = explode(' ', $str); $res = array_filter($parts, function($e){ return $e!=="" && strpos($e,".")===false; });
I recommend this method as it saves time . Otherwise, spending a few hours looking for a good regular expression is pretty unproductive .
source share