According to this, "If separator is a regular expression that contains capturing parentheses (), matched results are included in the array." To me, that's an unwanted side effect. I would like to split on a \n
or a <br>
string, and I don't know how to do this without using parentheses around it:
string.split(/(\n|\<br\>)/)
is there a way of writing this regex without parentheses? I don't want to include the separators in the result. Here's an example of it working incorrectly:
console.log("hi\nbye<br>foo".split(/(\n|\<br\>)/))