[Python-3000] Lines breaking
krstic at solarsail.hcs.harvard.edu
Tue May 29 11:47:04 CEST 2007
Ka-Ping Yee wrote:
> Hmm... would it? Or should two split points with nothing between
> them produce empty strings, i.e. you would have to do
> x.split(('\r\n', '\r', '\n'))
> to get the behaviour of x.splitlines()?
Right, Georg's example would be unintuitive given the current behavior
of str.split which will happily provide zero-width matches when it hits
separators in sequence.
Perl bypasses the issue by having split
(http://perldoc.perl.org/functions/split.html) take a regex; I've only
rarely used this for complex matches, though. I tried a Google code
lang:perl split\(?\s?\/\[ (simple multiple separators)
but the number of results seems to oscillate between 300 and 100000, so
that didn't help much.
Ivan Krstić <krstic at solarsail.hcs.harvard.edu> | GPG: 0x147C722D
More information about the Python-3000