There's got to be an easy way to do this (fwd)

Lulu of the Lotus-Eaters mertz at gnosis.cx
Thu Jul 5 19:33:16 CEST 2001


"Jeffery D. Collins" <jcollins at boulder.net> wrote in message
| re.sub("[^0-9]", "", "(555) 333.2221")

"Emile van Sebille" <emile at fenx.com> wrote:
| "".join([x for x in '(123)/456-7890' if x in '0123456789'])

  filter(lambda c:c.isdigit(), '(123)/456-7890')

Thirteen characters shorter than Emile's, and still no [re] :-).

Personally, I even find it easier to read.  YMMV.

Yours, Lulu...




More information about the Python-list mailing list