[Python-ideas] str.split with multiple individual split characters

Carl M. Johnson cmjohnson.mailinglist at gmail.com
Mon Feb 28 03:06:34 CET 2011


FWIW, I'd like it if something like this functionality existed in the
basic string methods. I'm aware of re.split, but in spite of learning
regular expressions two or three times already, I use them so
infrequently, I had already forgotten how to make it work and which
characters are special characters (I find this the hardest thing to
remember with regular expressions). So, I would appreciate it if
something like s.multisplit(["-", "_", ","]) existed.

Still, there is a simple enough non-regular expressions way of doing
such a split:

s = s.replace(",", "-").replace("_", "-")
items = s.split("-")

So, I don't think this is an urgent need. It's more of an "it would be
nice if" but I don't know how to square that against the maintenance
costs.



More information about the Python-ideas mailing list