D
darren
Hi
We have some code that makes a RegExp object out of a variable:
var xxx = new RegExp(aString);
The problem is that sometimes the string contains regular expression
characters so the match isn't happening as we would like. For example
I want to match the literal string "[1-1]" but when this is the
variable that is made into a RegExp, I think it is interpreted as a
range because of the [] characters. Is there anyway I can tell the
constructor that I want to match [1-1]? I basically want to escape
any special characters: \[1-1\]
thanks for any help.
We have some code that makes a RegExp object out of a variable:
var xxx = new RegExp(aString);
The problem is that sometimes the string contains regular expression
characters so the match isn't happening as we would like. For example
I want to match the literal string "[1-1]" but when this is the
variable that is made into a RegExp, I think it is interpreted as a
range because of the [] characters. Is there anyway I can tell the
constructor that I want to match [1-1]? I basically want to escape
any special characters: \[1-1\]
thanks for any help.