[Python-ideas] str.split with multiple individual split characters
Terry Reedy
tjreedy at udel.edu
Mon Feb 28 05:40:58 CET 2011
On 2/27/2011 9:06 PM, Carl M. Johnson wrote:
> 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
I found it so easy to get your particular use case -- multiple
individual chars -- right on my first attempt that I have trouble being
sympathetic. In the IDLE shell, I just typed re.split( and the tool tip
just popped up with (pattern, string, ...). The only thing I had to
remember is that brackets [] defines such sets.
> and which characters are special characters
It turns out that within a set pattern, special chars are generally not
special. However, extra backslashes do not hurt even when not needed.
Perhaps the str.split entry should have a cross-reference to re.split.
--
Terry Jan Reedy
More information about the Python-ideas
mailing list