REGULAR EXPRESSION

Ricardo Aráoz ricaraoz at gmail.com
Tue Sep 4 19:35:39 EDT 2007


Steve Holden wrote:
> 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...
>>
> Perhaps you could give a few example of strings that should and 
> shouldn't match? It isn't clear from your description what pattern you 
> are trying to find.
> 
> regards
>   Steve


If it's operations between two numbers try :
r'([\d.]+?)\s*([-+/*%&])([\d.]+)'
It will give you 3 groups, first number, operation and second number
(caveat emptor).



More information about the Python-list mailing list