Closed
Bug 453239
Opened 17 years ago
Closed 12 years ago
Non-recent capture-groups are forgotten inside alternations.
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: marjar-4, Unassigned)
Details
Attachments
(1 file)
1.33 KB,
text/html
|
Details |
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; sv-SE; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; sv-SE; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1
/^(?:(a)|(b))*$/.exec("ababa") returns ["ababa","a",""]
It forgets about the (b) capture-group that occured earlier. Most PCRE engines would remember the "b".
A little more practical example; URL query data matching.
A regex that would pick out query values independant of the order could be written like the following:
/^.*?/page\.php(?:[?&]key1=([^&]*)|[?&]key2=([^&]*)|[?&][^&]*)*$/
This should place the value of key1 into the first group, and the value of key2 into the second group, given that they both are supplied in the URL. But due to this bug, the value of all but the last key is forgotten.
Reproducible: Always
Steps to Reproduce:
1. Enter "javascript:alert(/^(?:(a)|(b))*$/.exec('ababa'))" into the address bar.
2. Press Enter
Actual Results:
"ababa,a,"
Expected Results:
"ababa,a,b"
Component: General → JavaScript Engine
Product: Firefox → Core
Open the file with a web browser and click the buttons.
Tests if a previously captured group is remembered.
Updated•16 years ago
|
QA Contact: general → general
Comment 2•12 years ago
|
||
I am pretty sure this is just how RegExp should behave in JS.
Status: UNCONFIRMED → RESOLVED
Closed: 12 years ago
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•