I'm trying to do a simple replace of a backslash occurence in a string. So I used the string.replace method, passing in a regex for the backslash to be removed \
.
But I noticed when I invoke this method, instead of replacing the backslash after EMEA with a colon :
character. It just removes the first letter in the username.
I've made a JSFIddle of the code here.
Not sure why the regex doesn't work as it's suggested in other SO answers here:
Replace all backslashes in a string with a pipe
Question:
How can you replace a backslash character with a semicolon?
Code gist:
var str = "EMEA\victorb";
str = str.replace(/\\/g, ':');
document.write(str);