Re: Is this a regex bug or just me?

Guido.van.Rossum@cwi.nl
Thu, 09 Feb 1995 10:45:52 +0100

> I think that the counting method is different from what you describe here.
> If I remember right, all regexp groups on one level are counted, then
> the next level and so on.
>
> Thus your example would be (0 (1) (2) (3 (4 (6)) 5))
>
> So the '26' DOES belong to group 5.
>
> I may be wrong though.

You are. Quoting from the Emacs info page on regexps:

The strings matching the first nine `\( ... \)' constructs
appearing in a regular expression are assigned numbers 1 through 9
in order that the open-parentheses appear in the regular
expression. `\1' through `\9' refer to the text previously
matched by the corresponding `\( ... \)' construct.

--Guido van Rossum, CWI, Amsterdam <mailto:Guido.van.Rossum@cwi.nl>
<http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>