Closed Bug 543663 Opened 14 years ago Closed 13 years ago

Adding a non capturing group causes spurious RegExp matches

Categories

(Rhino Graveyard :: Core, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 369860

People

(Reporter: mikesamuel, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.49 Safari/532.5
Build Identifier: Rhino 1.7 release 1 2008 03 06

Spurious regular expression matches occur when non-capturing groups are used.

The RegExp below fails.
  /(?:xy)$/

It should match any string and only strings that ends with xy, but spuriously matches some strings that do not even contain the character y.

Reproducible: Always

Steps to Reproduce:
Run the interactive shell as below:
> java -jar rhino/js.jar 
Rhino 1.7 release 1 2008 03 06
js> /(?:xy)$/.test("x")
true
js> /xy$/.test("x")
false
js> 
Actual Results:  
The javascript expression
    /(?:xy)$/.test("x")
yields true.

Expected Results:  
The javascript expression
    /(?:xy)$/.test("x")
yields false.
This is still present in the latest release.

)> java -jar /tmp/rhino1_7R2/js.jar 
Rhino 1.7 release 2 2009 03 22
js>  /(?:xy)$/.test("x")
true
js>  /xy$/.test("x")
false
js>
Hello,

here is another example of a regexp with non-capturing groups that fails. The example below should return true:

java -jar js.jar
Rhino 1.7 release 2 2009 03 22
js> /^(?:AB)|(?:CD)$/.test("CD")
false
My patch in pull request #19 ( https://github.com/mozilla/rhino/pull/19 ) will fix this bug.
Status: UNCONFIRMED → RESOLVED
Closed: 13 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.