string split without consumption

robert no-spam at not-existing.invalid
Sat Feb 2 17:17:42 CET 2008


Jeffrey Froman wrote:
> 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', '']
> 

Thanks, thats it


Robert



More information about the Python-list mailing list