I found this answer - http://stackoverflow.com/a/7943464/1901367 - which gave me this really useful code allowing me to parse search strings that contained quotes and white space.
preg_match_all('/(?<!")\b\w+\b|(?<=")\b[^"]+/', $subject, $result, PREG_PATTERN_ORDER);
I wondered if someone could tell me how to alter this code so that it would leave boolean operators such as + and - intact because the current code strips them out.
I want to do fulltext boolean searches of my database making use of those operators and I am confused by this REGEX which I don't understand.
Example input and output.
Input: '"this is some" text here is -more -"exlude me"' Output: [this is some] [text] [here] [is] [-more] [-exclude me] these would be in the $result array
So everything seperated by a space is an individual item unless it is a phrase enclosed in "". This works already but where I have -more and -"exlude me" the result currently would be [more] and [exclude me] losing the minus symbol which I want to keep.
Thanks in advance!