6 Replies Latest reply on Oct 9, 2008 10:50 AM by try67

    [JS] Reg Exp Error when using *

    CTC Imaging Level 1
      Hello everyone,

      I get a syntax error when executing a script which contains RegExp handling strings with "*".
      ie:
      var x = /\*\*\*ABC/;
      alert (RegExp(x)); //*** WORKS because x is defined as an EXPRESSION
      var x = "\*\*\*ABC";
      alert (RegExp(x)); //*** SYNTAX ERROR when executing
      var x = "***ABC";
      alert (RegExp(x)); //*** SYNTAX ERROR when executing

      My problem is I have to build the expression using strings. So I was hoping to concatenate the string portionsa and use New RegExp to create my expression. Unfortunately, if we have STARS (*) in the string you get an error. Which as forced me to HARDCODE and I whish not to.
      ie:
      alert (yyy.search(/\*\*\*ABC/);

      FYI: I have expample in HTML where ".value" is used. But it does not work w/ InDesign???
      ie:
      var re = new RegExp(document.demoMatch.regex.value);
      if (document.demoMatch.subject.value.match(re))
      alert("Successful match");
      else
      alert("No match");

      Any suggestions?