how to split text into lines?
alex23
wuwei23 at gmail.com
Thu Jul 31 01:26:04 EDT 2008
kj wrote:
> 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?
re.split(os.linesep, <string>) works the same as <string>.splitlines()
Neither retain the EOL for each line, though. The only way I'm aware
of is to re-add it:
[s+os.linesep for s in re.split(os.linesep, <string>)]
Was that what you were after?
More information about the Python-list
mailing list