Folks,
I'm trying to replace a huge chunk of string with a multiple occurrences of "${country_id}"
. I need a Regular expression that can replace the ${country_id}
. Here is the code I have:
var iterLiteral = "\$\{"+literal+"\}"
var re = new RegExp(iterLiteral,"g")
var value = value;
return body.replace(re,value)
I get this error:
Evaluator: org.mozilla.javascript.EcmaError: Invalid quantifier }
How can I fix it?
Edit:
String to be replaced: ${country_id}
literal
being passed to the function : country_id
.
Trying to use what Anubhava said ( using \\
), the program tries to search for \$\{country_id\}
and it doesn't find one.
Edit 2: Why is this a duplicate? the question that was mentioned doesn't talk about escaping.