Javascript Error, unmatched ) in regular expression, when escaping the ) in question (using a \ before it)

RESOLVED INVALID

Status

()

Core
JavaScript Engine
RESOLVED INVALID
8 years ago
8 years ago

People

(Reporter: troomps01, Unassigned)

Tracking

1.9.2 Branch
x86
Windows 7
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

8 years ago
User-Agent:       Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET CLR 1.1.4322)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)

Firefox doesn't seem to like escaped )s in its regualr expressions. Running this regular expression:
"[ ][-]?[0-9]*[\.]?[0-9]*[\]|\)]"
Provides a Javascript error "unmatches ) in regular expression". As you can see the one paren in the expression is escaped, so it should be treated as a character, not operator.

Reproducible: Always

Steps to Reproduce:
1.Plug in a piece of code like so: 
      rangeString = "[0, 1]";
      rangeString = rangeString.split(",");
      var a = ""+rangeString[0].match("[\[|\(][-]?[0-9]*[\.]?[0-9]*");
      var b = ""+rangeString[1].match("[ ][-]?[0-9]*[\.]?[0-9]*[\]|\)]");
2. Run the code (is Javascript)
3. Error occurs at on line 4.
Actual Results:  
A Javascript error occurs on the page, which is problematic as the above code it a portion of a form validation script, the form is counted as never valid in Firefox, it works in all other browsers... annoying when trying to code cross-browser websites.

Expected Results:  
Given that the ) is escaped it should be treating it as a character instead of a regular expressions operator.
Assignee: nobody → general
Component: General → JavaScript Engine
Product: Firefox → Core
QA Contact: general → general
Version: unspecified → 1.9.2 Branch
You need two backslashes to escape within a string.  "\)" === ")", "\\)" is what you want.
Status: UNCONFIRMED → RESOLVED
Last Resolved: 8 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.