any way to escape the expression when constructing a RegExp object?
- From: darren <minofifa@xxxxxxxxx>
- Date: Mon, 26 May 2008 10:28:02 -0700 (PDT)
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.
.
- Follow-Ups:
- Re: any way to escape the expression when constructing a RegExp object?
- From: Lasse Reichstein Nielsen
- Re: any way to escape the expression when constructing a RegExp object?
- From: Bjoern Hoehrmann
- Re: any way to escape the expression when constructing a RegExp object?
- Prev by Date: Re: Remove Empty Tags on page
- Next by Date: Re: any way to escape the expression when constructing a RegExp object?
- Previous by thread: Remove Empty Tags on page
- Next by thread: Re: any way to escape the expression when constructing a RegExp object?
- Index(es):
Relevant Pages
|