how to get all repeated group with regular expression
M.-A. Lemburg
mal at egenix.com
Fri Nov 21 12:35:05 EST 2008
On 2008-11-21 15:31, scsoce wrote:
> say, when I try to search and match every char from variable length
> string, such as string '123456',
??? That's a strange requirement. If you want to match every character,
then why are you using a regular expression for this ?
> i tried re.findall( r'(\d)*, '12346' )
> , but only get '6' and Python doc indeed say: "If a group is contained
> in a part of the pattern that matched multiple times, the last match is
> returned."
> cause the regx engine cannot remember all the past history then ? is it
> nature to all regx engine or only to Python ?
>>> list(re.match( r'(\d*)', '12346' ).group(1))
['1', '2', '3', '4', '6']
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, Nov 21 2008)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
2008-11-12: Released mxODBC.Connect 0.9.3 http://python.egenix.com/
:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
More information about the Python-list
mailing list