I need to split a string with a backslash.
I M \ SPLITTING
My expected result :
[ "I M ", " SPLITTING" ]
I have tryied the following :
console.log(("I M \ SPLITING").split("\"));
console.log(("I M \ SPLITING").split("\\"));
Works fine with slash :
console.log(("I M / SPLITING").split("/"));
Actually, your string does not contain backslash, interpreter thinks its a single escape character. Try this solution
console.log(("I M \\ SPLITING").split("\\"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With