Tuesday, 6 August 2013

Python regex to remove all words which contains number

Python regex to remove all words which contains number

I try to make a python regex expression which allow me to remove all
worlds of a string with number.

Foor example :
in = "ABCD abcd AB55 55CD A55D 5555"
out = "ABCD abcd"<br>

the regex for delete number is trivial :
print(re.sub(r'[1-9]','','Paris a55a b55 55c 555 aaa'))

But I don't know how delete the entire word and not juste the number.

Could you help me please ?
Thanks

No comments:

Post a Comment