$input = "some words go here priority: p1,p2 -rank:3 status: not delayed";
$pattern = "/(\S+):\s*(.*?)(?=\S+:|$)|(.*?)(?=\S+:|$)/";
preg_match_all($pattern, $input, $matches);
Example: http://regex101.com/r/yM0wO1#pcre
The above pattern ends up outputting an extra empty array at the end. (See Match 5 in the example)
Everything else is the way I expect it to be...
How can I prevent the extra empty array?
EDIT: BACKGROUND INFO
I have data formatted as such:
some words go here priority: p1,p2 -rank:3 status: not delayed
Basically I need to retrieve each set of data that corresponds to the colon name.
Ideally if I could end up with an array structure such that
'' => 'some words go here'
priority => 'p1,p2'
-rank => 3
status => 'not delayed'
A few caveats:
keywords will not have a defining colon-word (keywords are just placed in the front)
keywords will not always exist (might just be colon-words)
colon-words will not always exist (might just be keywords)