I've written a regex to split a search string into its component parts. Features include:
- Operators:
+
,-
,AND
,OR
- Word grouping by quotes (single and double for now)
- Correctly ignoring apostrophes
So:
((?<=^|\s)(?:[\+\-]?"[^"]+"(?=\s|$)|[\+\-]?'[^']+'(?=\s|$)|[\+\-]?\S+|AND|and|OR|or)(?=$|\s))
What is the easiest way to exclude the delimiter quotes from the result matches? Example:
lsdkjflws's ldkj and "lfldkfjs's ldkjfls" lskdj
results in these pieces:
- lsdkjflws's
- ldkj
- and
- "lfldkfjs's ldkjfls"
- lskdj
I don't need to do this, I'd just like to accomplish one more step in the regex.