I am running a split in javascript with /\s+(AND|OR)(?=\s+")\s+/
on
"email" IS NOT NULL AND "email" LIKE '%gmail.com' OR "email" = '[email protected]'
Now, my understanding of regular expressions would lead me to expect obtaining the following array:
[0]: "email" IS NOT NULL
[1]: "email" LIKE '%gmail.com'
[2]: "email" = '[email protected]'
Note: I got rid of the delimiters for clarity.
However, I obtain
[0]: "email" IS NOT NULL
[1]: AND
[2]: "email" LIKE '%gmail.com'
[3]: OR
[4]: "email" = '[email protected]'
when running on Firefox 3.6.8, Chrome 5.0.375.126 and Safari 5.0.1 on OS X 10.6.4.
However, when I tried on an up to date IE8 8.0.6 with default settings and I obtain what I was expecting at first. PHP 5.2.10 with preg_split
does also split it this way.
My guess is that for once the 'good' browsers got it wrong but I'd like more opinions.
Edit: The example I gave here with emails is a naive example. Basically I don't know what each member can be. "xyz" = '1' AND "zyx" = 'test AND toast'
is another possible input string.
What I know of the structure is that the whole string will have the following pattern:
"<attribute>" <operator> '<value>'( (AND|OR) "<attribute>" <operator> '<value>')*
Note: spaces actually represent \s+