Regular Expression pattern group

Ant antroy at gmail.com
Thu Jun 15 03:13:28 EDT 2006


> I am a fussy learner. Could someone explain to me why the following
> inconsistency exists between methods? How can it be justified if it is
> considered all right?

It's the standard way of accessing groups from regex matches in pretty
much all languages that support them. In most modern languages, I
believe regexes are generally designed to be compatible with Perl
regexes - but these I guess derive from earlier languages like awk and
sed.

So it's not an inconsistency. Think of 0 as being an implicit group
around the entire expression.

In addition, if the match around the entire group was only accessible
via a different method, then how would you refer to the entire match in
back-references/substitutions?




More information about the Python-list mailing list