Connecting Tech Pros Worldwide Help | Site Map

Re: how to get all repeated group with regular expression

M.-A. Lemburg
Guest
 
Posts: n/a
#1: Nov 21 '08
On 2008-11-21 15:31, scsoce wrote:
Quote:
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 ?
Quote:
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 ?
Quote:
Quote:
Quote:
>>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)
Quote:
Quote:
Quote:
>>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
Closed Thread