REGULAR EXPRESSION

Jonathan Gardner jgardner.jonathangardner.net at gmail.com
Tue Sep 4 15:47:11 EDT 2007


On Sep 4, 6:32 am, AniNair <anitn... at gmail.com> 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...

You may want to read the page describing the regex syntax a little
closer. http://docs.python.org/lib/re-syntax.html

\W would match anything but \w. That is, it would match spaces and
tabs as well as the weird characters. I don't think that's what you
want.

Also, don't forget to use raw strings. r"\W+" is preferred over "\W+".




More information about the Python-list mailing list