2 Replies Latest reply on Apr 10, 2009 12:18 AM by ab1301

    Backslash does not escape dot in regular expression

    ab1301

      I am trying to determine whether a string contains a dot character.

       

      Here is the regular expression:

       

      var dotpattern:RegExp = new RegExp("\.", "");

       

      when I test a string with no dots, as such:

       

      dotpattern.test("this string has no dots");

       

      it evaluates as "true," even though there are no dots.  When I use exec to find out what is matching, it is always the first character, in this example, "t."  I take it this means the \ is not escaping the dot character.  Why not?  How do I make it work?