[Tutor] Remove specific chars from a string
Malcolm Greene
python at bdurham.com
Mon Apr 14 19:55:09 CEST 2008
What is the Pythonic way to remove specific chars from a string? The
.translate( table[, deletechars]) method seems the most 'politically
correct' and also the most complicated.
My ideas:
1. For each char to be removed, do a .replace( char_to_delete, '' )
2. Do a .split( str_of_chars_to_delete ) followed by a ''.join()
3. Use a regular expression
4. Other?
Thanks!
Malcolm
More information about the Tutor
mailing list