Perl RegExp test 419: /^(a\1?){4}$/.exec('aaaaaaaaaa')

RESOLVED INVALID

Status

()

RESOLVED INVALID
12 years ago
7 years ago

People

(Reporter: bc, Unassigned)

Tracking

Trunk
x86
All
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

12 years ago
expected aaaaaaaaaa,aaaa (MSIE6 agrees)
actual   null

note that Perl RegExp test 420 /^(a\1?){4}$/.exec('aaaaaaaaa') is null in SpiderMonkey and MSIE6

Comment 1

11 years ago
there is actually an even simpler example:
search for a sequence of either 'a's or 'b's (like in /^(a+|b+)/):
((^a)|(^b)|\1)+

Comment 2

11 years ago
Wondering if x00000000 has any thoughts on this bug.

Comment 3

11 years ago
null is the correct result per ECMA because step 4 of RepeatMatcher sets all inner captures to undefined. SpiderMonkey fails to do that (bug 369778), but if the left parenthesis is visited again, then it will set its capture to the empty string, and that's what a backreference to an undefined capture should match.

In ECMAScript, a backreference at the left hand side of the corresponding right parenthesis is always equivalent to (?:).
Status: NEW → RESOLVED
Last Resolved: 7 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.