The nut is cracked! Still it is two step check. Judge yourself if it
is terse or not :)
1. The main regex.
Most of the examples including listed below
keyword:model train locomotive
keyword:redline
sellerid:allwheels2go
keyword:truck sellerid:allwheels2go
keyword:model train locomotive minbid:1
keyword:model train locomotive minbid:1 maxprice:50
categoryid:19175 minbid:1
categoryid:19175 desc:"flower:grown"
keyword:redline sort:bidcount
keyword:chevy truck maxdistance:100 miles
sellerid:bob,john,james,jim
sellerid:bob sellerid:john sellerid:james sellerid:jim
will be covered by regex
(\w+)\:\"?([^\r\n]+?)(?=(?:\"|\x20\w+\:|[\r\n]+|\Z))
if you grep through the line (repeat the search cyclically)
2. The check.
Now we have out of order things like
model train locomotive //no command at all
"flower:grown" //the value itself contains colon
not covered by our regex.
Not to get stuck on this, you FIRST need to check if your subject
string against
^(([a-z0-9\x20]+)|\"([a-z0-9:]+)\")$
And if that matches, use backreference $1 or $2 as collected value.
The one which is not empty is what you need. That'll be the value.
Prepend that value with "keyword" or whatever your setting is.
--------------------
What i described in step2 should in fact be the first check because
"flower:grown"
on a line by itself can be matched by the main regex and therefore
"flower" will be considered as command and "grown" as value, while
this is undesired. To avoid this, don't feed the subject string to the
main regex if the check gives you positive alert.
--
Regards, Eugeny