AniNair anitnair at
Wed Sep 5 07:03:52 CEST 2007

On Sep 5, 4:35 am, Ricardo Aráoz <ricar... at> 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.
> > 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).

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...

More information about the Python-list mailing list