how to find specific special character from string and replace it to unicode u0026 + = u002B
replace only these special character : [$, &, +, #]
example : “HELLO JAMES (WITH ME YOUR) n+++ SEE & FIELD 4-B +++
MY code
var char = '+';
var saa =char.charCodeAt(0);
console.log(saa)
var codeHex = saa.toString(16).toUpperCase();
while (codeHex.length < 4) {
codeHex = "0" + codeHex;
}
var afteruni = name.replaceAll('+','\u'+codeHex)
i want like this :
“HELLO JAMES (WITH ME YOUR) nu002Bu002Bu002B SEE u0026 FIELD 4-B
u002Bu002Bu002B”
ERROR : Invalid regular expression: /+/: Nothing to repeat