You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Splitting a string normally leaves out the delimiters.
> "a and b or c".split(/and|or/)
["a ", " b ", " c"]
But grouping-parentheses in a regular expression preserves them in the odd-numbered indexes of the output.
> "a and b or c".split(/(and|or)/)
["a ", "and", " b ", "or", " c"]
This was not supported in IE before version 11. And MDN says "not all browsers support this capability." I'd like to see whether other browsers support this feature. But the current information in caniuse.com does not address this.
These methods are supported in effectively all browsers (since IE6+, Firefox 2+, Chrome 1+ etc)
The text was updated successfully, but these errors were encountered:
These are all interrelated concepts with different support histories, but none of them explicitly mention splitting with groupings as a separate caveat. In fact, even the aforementioned MDN page has removed the aforementioned statement about (lack of) support.
Splitting a string normally leaves out the delimiters.
But grouping-parentheses in a regular expression preserves them in the odd-numbered indexes of the output.
This was not supported in IE before version 11. And MDN says "not all browsers support this capability." I'd like to see whether other browsers support this feature. But the current information in caniuse.com does not address this.
The text was updated successfully, but these errors were encountered: