string split without consumption
Jeffrey Froman
jeffrey at fro.man
Sat Feb 2 11:10:14 EST 2008
robert wrote:
> thanks. Yet this does not work "naturally" consistent in my line
> processing algorithm - the further buffering. Compare e.g.
> ss.split('\n') ..
>
> >>> 'owi\nweoifj\nfheu\n'.split('\n')
> ['owi', 'weoifj', 'fheu', '']
> >>> 'owi\nweoifj\nfheu\nxx'.split('\n')
> ['owi', 'weoifj', 'fheu', 'xx']
Maybe this works for you?
>>> re.split(r'(\n)', ss)
['owi', '\n', 'weoifj', '\n', 'fheu', '\n', '']
Jeffrey
More information about the Python-list
mailing list