There's got to be an easy way to do this

Peter Biela Peter.Biela at planet-interkom.de
Thu Jul 5 15:12:34 EDT 2001


Hi Greg,

you should be able to use simple a opertaion vom the re Modul, using regular
expresion syntax.
This line, should return you a string from which any non Digits  '\D' were
substituted by '', phone_number is your original string upon, which the sub
methode is used!

import re
stripped_phone = re.sub('\D','',phone_number)

I hope, this works!

Peter Biela





More information about the Python-list mailing list