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

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, "");
| improve this answer | |
  • No bueno - still fails with v42. – dzh May 22 '18 at 16:49
  • @dzh Yeah, I just tested that (again). I came up with a viable alternative that does compile, though. – sfdcfox May 22 '18 at 16:57
  • @sfdcfox Can you share what your "viable alternative" was? – zachelrath Oct 3 '18 at 20:09
  • 1
    @zachelrath The last edit: var regex = new RegExp("'","g"); – sfdcfox Oct 3 '18 at 20:14
  • any alternatives? – Jitender Padda Dec 5 '18 at 6:52

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.