regular expressions an text string
s0suk3 at gmail.com
s0suk3 at gmail.com
Thu Apr 17 03:30:04 EDT 2008
On Apr 17, 2:09 am, ragia <ragi... at hotmail.com> wrote:
> hi
> i have to match text string char by char to a regular expressions tht
> just allow digits 0-9 if other thing a ppear it shall be replaced with
> space.how can i do that any help?
> so far i have the string and can read it using a for loop...but how to
> match each char with the regular expressions and save the result into
> other string or replace it with space in that other string to have new
> one..
> I a new in python ,thatnks in advance
>>> import re # Python's library supporting regexps
>>>
>>> string = "abc123def456"
>>> re.sub("\D", " ", string)
' 123 456'
~~Sosuke~~
More information about the Python-list
mailing list