Regex: How should backreferences contained in the capturing match they reference to work?

Lars T Hansen lth at
Fri Sep 14 01:25:36 PDT 2007

On 9/14/07, Brendan Eich <brendan at> wrote:
> I am not looking to make trouble here, believe me, but I want to
> point out two things that could help David's case:
> 1. JS regexps were modeled by me (to lwall's horror ;-) on Perl
> regexen. Here's what perl (5.8.8) does:
> $ perl
> "aaab" =~ /(a\1)+|b/;
> print "$& ($1)\n";
> b ()
> It's no surprise JavaScriptCore agrees, since it is based on PCRE.
> Tamarin is too -- do you know what it does?
> 2. IE JScript does not agree with any of Perl/JavaScriptCore or ES3
> and conformant implementations. That does not mean it should prevail
> for this edge case. But it does suggest we could change to match
> Perl, and match David's two-person (three counting him; perhaps four
> if I count ;-) developer sample.

I oppose this on merely Perl compatibility grounds -- ES regexes have
since evolved through other influences -- but sure, we'll give it a
fair hearing.  I propose that everyone involved wait until the draft
library spec is released (soon, if all goes well) and that specific
proposals to changes in regexp semantics are made in terms of that
draft spec.  (It should be somewhat easier to deal with than the ES3
spec would be.)


More information about the Es4-discuss mailing list