REGULAR EXPRESSION

Tuomas tuomas.vesterinen at pp.inet.fi
Tue Sep 4 17:33:55 CEST 2007


AniNair wrote:
> hi.. I am trying to match '+ %&/-' etc using regular expression  in
> expressions like 879+34343. I tried \W+   but it matches only in the
> beginning of the string Plz help Thanking you in advance...
> 

Is this what you are seeking for?

 >>> re.compile('(\+{0,1})?([0-9]+)').findall('879+34343')
[('', '879'), ('+', '34343')]

Tuomas Vesterinen



More information about the Python-list mailing list