string split without consumption
no-spam at not-existing.invalid
Sat Feb 2 16:14:18 CET 2008
Tim Chase wrote:
>> this didn't work elegantly as expected:
>> >>> ss
>> >>> re.split(r'(?m)$',ss)
> Do you have a need to use a regexp?
I'd like the general case - split without consumption.
> ['owi\n', 'weoifj\n', 'fheu\n']
thanks. Yet this does not work "naturally" consistent in my line
processing algorithm - the further buffering. Compare e.g.
['owi', 'weoifj', 'fheu', '']
['owi', 'weoifj', 'fheu', 'xx']
is consistent in that regard: there is always a last empty or half
line, which can be fed readily as start to the further input
With the .splitlines(True/False) results you need to fiddle, test
the last result's last char... Or you fail altogether with False.
So I'd call this a "wrong" implementation.
More information about the Python-list