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?
Please try making the changes as shown below.
var dotpattern:RegExp = new RegExp("\\.", "");
Hope this helps.
Perfect. Thanks. Why do you need the double backslash?