I want to replace DoubleQuote from a specific JavaScript String in Aura Helper component using Regular Expression.

My JS String is ab ","{ cd

I want it to be ab ,{ cd

I am performing this operation:

var data = "ab \",\"{ cd";
data = data.replace(/\",\"{/g, ",{"); // Getting error at this line

But, every time I am receiving a Salesforce error message, while performing the 2nd line

org.auraframework.util.json.JsonStreamReader$JsonStreamParseException: Unterminated string [300, 46]: ');': Source

Please advice.


  • It looks like the string you are manipulating is a JSON in the string representation and after you have done the manipulation, it is no longer a valid JSON. – manjit5190 May 12 '20 at 11:52
  • @manjit5190 Yes. Probably you are correct.. – Kamruzzaman May 12 '20 at 13:12

Following works fine for me

var data = "ab \",\"{ cd";
var ex=new RegExp("\"","g");

also Single Quote not getting replaced with Blank in lightning

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.