Regexp capturing groups.
liorean at gmail.com
Thu Sep 4 11:10:00 PDT 2008
2008/9/4 Markus Jarderot <marjar-4 at student.ltu.se>:
> When I first noticed this in Firefox I thought it was a bug. After some
> investigation it turns out that the problem was in the specification.
> What I am talking about is that ES discards the capturing groups on
> repetition. I don't know of any Regexp engine which is not based on the
> ECMA-262 standard that behaves like this.
Neither do I, which I pointed out a few times in the prior discussions
on the topic.
> I don't know if any web application depends on this behavior, but I
> wouldn't write any code that did.
Well, I'm sure you will find some code out there if you were to spider
for it. However, changing the behaviour would:
+ Make the behaviour match that of regex in other languages, and
realign the ECMAScript regex with the Perl regex they are based on.
+ Make the behaviour more intuitive even for developers without prior
experience of regex in other languages or who read regex tutorials
that are not language specific.
+ Increase the overall usefulness of ECMAScript regex by increasing
the problem space they can provide solutions within.
- Probably break a very small amount of live code.
> This problem, and that of back-references to non-participating groups,
> have been discussed on this list before, but nothing seems to have come
> out of it.
I also made my argument in
and Steven Levithan had already made an argument like it in
I've not seen anything come out of it, which I blame myself for
because I raised the issue but didn't enter a ticket on it in trac. Of
course, the reason I didn't enter it was that Steven Levithan says in
this blog entry
had planned to submit it but wanted to see where his other regex
tickets went first. So it ended up just a mailing list discussion and
not much else.
David "liorean" Andersson
More information about the Es-discuss