Replace Character In Javascript
I need replace a character in a string for a backslash, example var string = 'hello world!'; string.replace('!','\'); help me please thanks!!!!
Solution 1:
You can use:
string = string.replace(/!/g, '\\');
backslash needs to be escaped with another backslash and better to use regex /!/
in order to replace all the occurrences of !
Post a Comment for "Replace Character In Javascript"