A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-August/047226.html below:

Complete, Structured Regular Expression Group Matching

[Python-Dev] Re: pre-PEP: Complete, Structured Regular Expression Group MatchingMike Coleman mkc at mathdogs.com
Sat Aug 7 05:59:04 CEST 2004
"Raymond Hettinger" <python at rcn.com> writes:
> > A notable limitation of the ``re.match`` method is that it fails to
> > capture all group match information for repeatedly matched groups.
> > For example, in a call like this ::
> > 
> >     m0 = re.match(r'([A-Z]|[a-z])*', 'XxxxYzz')
> > 
> > one would like to see that the group which matched four times matched
> > the strings ``'X'``, ``'xxx'``, ``'Y'`` and ``'zz'``.  
> 
> I suspect there is a typo in the example and that the asterisk should
> precede the right paren:
> 
>      m0 = re.match(r'([A-Z]|[a-z]*)', 'XxxxYzz')

Oops, you are correct.  In fact, I was thinking of 

       m0 = re.match(r'([A-Z]*|[a-z]*)', 'XxxxYzz')

when I wrote this, but since only single capitals are given in my example, it
could be either.

Fixed.  Thanks!
Mike

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4