Splitting a string with a regex including a choice point (such as (a|b) ) will cause the splitting tokens to be part of the resulting array. Test case: var string = "'test1' and 'test2' or 'test3'"; alert(string.split(/(and|or)/)); Actual result: ["'test1 ", "and", " 'test2' ", "or", " 'test3'"] Expected result: ["'test1 ", " 'test2' ", " 'test3'"]
Correction to the results sample (missing single quote after test1): Actual result: ["'test1' ", "and", " 'test2' ", "or", " 'test3'"] Expected result: ["'test1' ", " 'test2' ", " 'test3'"]
Correct behavior as per the ECMAScriptv5 specs section 15.5.4.14 Sorry for the noise.