[Python-ideas] Easily remove characters from a string.
Chris Barker
chris.barker at noaa.gov
Mon Oct 24 13:48:08 EDT 2016
On Mon, Oct 24, 2016 at 8:21 AM, Michel Desmoulin <desmoulinmichel at gmail.com
> wrote:
> This actually could be implemented directly in str.replace() without
> breaking the API by accepting:
>
> "stuff".replace('a', '')
> "stuff".replace(('a', 'b', 'c'), '')
> "stuff".replace(('a', 'b', 'c'), ('?', '*', ''))
>
+1 -- I have found I Need to do this often enough that I've wondered why
it's not there.
making three calls to replace() isn't too bad, but is klunky and has
performance issues.
-CHB
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20161024/93901d1b/attachment.html>
More information about the Python-ideas
mailing list