On Sun, Feb 27, 2011 at 6:40 PM, Terry Reedy <tjreedy@udel.edu> wrote:
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.
Yes, but brackets defining such sets is the exact thing that I had forgotten! :-P
It turns out that within a set pattern, special chars are generally not special. However, extra backslashes do not hurt even when not needed.
Things like this are what make me think it is impossible for regular expressions, as useful as they are, to be really Pythonic. There are too many "convenient" special cases. Anyway, you'll get no argument from me: Regexes are easy once you know regexes. For whatever reason though, I've never been able to successfully, permanently learn regexes. I'm just trying to make the case that it's tough for some users to have to learn a whole separate language in order to do a certain kind of string split more simply. Then again that's not to say that there needs to be such functionality. After all, love them or hate them, there are a lot of tasks for which regexes are just the simplest way to get the job done. It's just that users like me (if there are any) who find regexes hard to get to stick would appreciate being able to avoid learning them for a little longer.