ricaraoz at gmail.com
Wed Sep 5 12:03:09 CEST 2007
> On Sep 5, 4:35 am, Ricardo Aráoz <ricar... at gmail.com> wrote:
>> 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.
>> If it's operations between two numbers try :
>> It will give you 3 groups, first number, operation and second number
>> (caveat emptor).
> Hi.. Thanks alot for finding time to help a beginner like me. What I
> am trying to do is validate the input i get. I just want to take
> numbers and numbers only. So if the input is 23+1 or 2/3 or 9-0 or
> 7/0 , I want to find it using reg exp. I know there are other ways to
> do this... but i thought i will try this as i need to learn reg exp. I
> tried \D+ , \W+, and \D+|\W+ .. Thanks once again...
Well \d will match a number and '.' inside  will match a dot ;) so if
you want only integer numbers ([\d.]*) should be replaced with (\d+)
Only problem with the expression I sent is that it will match a number
with more than one dot.
More information about the Python-list