I have a text that contains:
var str = 'Coins ++';
I need to replace it with 'Coins plusplus'
The following doesn't work:
str = str.replace(/+/g , "plus");
How to get this done?
use with \ before the plus. because + is one of the special character of the regex
var str = 'Coins ++';
str = str.replace(/\+/g, "plus");
console.log(str)
+using \ likestr.replace(/\+/g, "plus")+is a special character in RegExp patterns, being a shorthand for a{1,}(one or more) quantifier.