I'm trying to split a string including the delimeters, so for example
"a/b/c"would become["a/", "b/", "c"]"a//b"would become["a/", "/", "b"]
var s = "a/b/c".split(/(?<=\/)/);
console.log(s); // prints ["a/", "b/", "c"]
It works perfectly fine in Chrome, but Firefox says: SyntaxError: invalid regexp group
Hence my questions:
- Is the code legal?
- How to make it work in Firefox and Edge?