how to split text into lines?

Miles semanticist at gmail.com
Wed Jul 30 17:55:10 EDT 2008


On Wed, Jul 30, 2008 at 4:45 PM, kj wrote:
>>What's the Python idiom for splitting text into lines, preserving
>>the end-of-line sequence in each line?
>
>
> Sorry, I should have googled this first.  I just found splitlines()...
>
> Still, for my own edification, is there a way to achieve the same
> effect using re.split?

Not directly: re.split doesn't split on zero-length matches.

http://mail.python.org/pipermail/python-dev/2004-August/047272.html
http://bugs.python.org/issue852532
http://bugs.python.org/issue988761
http://bugs.python.org/issue3262

-Miles



More information about the Python-list mailing list