/\1/ could be a valid RegExp through Chapter 16 Extension clause?

Mike Samuel mikesamuel at gmail.com
Thu Jul 7 14:59:16 PDT 2011

2011/7/7 Brendan Eich <brendan at mozilla.com>:
> On Jul 7, 2011, at 2:40 PM, Lasse Reichstein wrote:
>> On Thu, 07 Jul 2011 21:17:17 +0200, Mike Samuel <mikesamuel at gmail.com> wrote:
>>> One way to tell whether the group initialized to empty works on an
>>> interpreter is to test
>>>    /^(?:\1x(y)x){2}$/.test("xyxyxyx")
>>> which is true in most interpreters, but false in Rhino1.7 and Chrome12.
>> I do believe it should be false. The captures are cleared for each iteration
>> of a quantified atom (RepeatMatcher in section, step 4), so the \1 will
>> always be non-participating (and match the empty string).
> Agreed.

Would that mean that

    /^(?:\1x(y)x){2}$/.test("xyxxyx") && !/^(?:\1x(y)x){2}$/.test("xyxyxyx")

If so, V8 agrees with that, the species of monkey in FF 5 does not,
the JsCore in Safari 533.21 does not, and Rhino does.

>>> Interestingly other perl 5 interpreters
>> I don't think ES RegExps should count as a PCRE :)
> +1 (and I'm the guy who copied perl4 in the pre-ES3 cowpath treading exercise that led to the ES3 paving of RegExp's cowpath; I even apprised lwall of the plan, saying it would lead to an ISO standard -- he turned three shades of green ;-)
> /be

More information about the es-discuss mailing list