6

I have an expression and I am trying to replace all single quote with blank but when I try to save my controller.js it gives error:

Error: 0Adf4000000en6S: org.auraframework.util.json.JsonStreamReader$JsonStreamParseException: Unterminated string [96, 41]: '/g, "");

I am trying this code:

var sqlExpression = 'gattexlead_flag'_1;
var text1 = sqlExpression.replace(/'/g, "");

1 Answer 1

1

This is probably a bug with the lexer. You will probably need to escape it:

var text1 = sqlExpression.replace(/\'/g, "");

For now, if you need a regular expression that fails to compile, compile it ahead of time:

var regex = new RegExp("'","g");
var text1 = sqlExpression.replace(regex, "");
5
  • No bueno - still fails with v42.
    – dzh
    Commented May 22, 2018 at 16:49
  • @dzh Yeah, I just tested that (again). I came up with a viable alternative that does compile, though.
    – sfdcfox
    Commented May 22, 2018 at 16:57
  • @sfdcfox Can you share what your "viable alternative" was?
    – zachelrath
    Commented Oct 3, 2018 at 20:09
  • 1
    @zachelrath The last edit: var regex = new RegExp("'","g");
    – sfdcfox
    Commented Oct 3, 2018 at 20:14
  • any alternatives? Commented Dec 5, 2018 at 6:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .