Steve Holden wrote:
> robert wrote:
> [...]
>> but its also wrong regarding partial last lines.
>>
>> re.split obviously doesn't understand \A \Z ^ $ and also \b etc. empty
>> matches.
>>
> [...]
> Or perhaps you don't understand re?
>
> It's a tricky thing to start playing with. Look up re.MULTI
robert wrote:
[...]
> but its also wrong regarding partial last lines.
>
> re.split obviously doesn't understand \A \Z ^ $ and also \b etc.
> empty matches.
>
[...]
Or perhaps you don't understand re?
It's a tricky thing to start playing with. Look up re.MULTILINE ans
re.DOTALL.
regards
Ste
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'.
Tim Chase wrote:
this didn't work elegantly as expected:
>>> ss
'owi\nweoifj\nfheu\n'
>>> re.split(r'(?m)$',ss)
['owi\nweoifj\nfheu\n']
>>> Do you have a need to use a regexp?
>> I'd like the general case - split without consumption.
>
> I'm not sure there's a one-p
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'
>>> this didn't work elegantly as expected:
>>>
>>> >>> ss
>>> 'owi\nweoifj\nfheu\n'
>>> >>> re.split(r'(?m)$',ss)
>>> ['owi\nweoifj\nfheu\n']
>> Do you have a need to use a regexp?
>
> I'd like the general case - split without consumption.
I'm not sure there's a one-pass regex solution to the
Tim Chase wrote:
>> this didn't work elegantly as expected:
>>
>> >>> ss
>> 'owi\nweoifj\nfheu\n'
>> >>> re.split(r'(?m)$',ss)
>> ['owi\nweoifj\nfheu\n']
>
> Do you have a need to use a regexp?
I'd like the general case - split without consumption.
>
ss.splitlines(True)
> ['owi\n', 'weoi
> this didn't work elegantly as expected:
>
> >>> ss
> 'owi\nweoifj\nfheu\n'
> >>> re.split(r'(?m)$',ss)
> ['owi\nweoifj\nfheu\n']
Do you have a need to use a regexp?
>>> ss.splitlines(True)
['owi\n', 'weoifj\n', 'fheu\n']
-tkc
--
http://mail.python.org/mailman/listinfo/python-list
this didn't work elegantly as expected:
>>> ss
'owi\nweoifj\nfheu\n'
>>> re.split(r'\A',ss)
['owi\nweoifj\nfheu\n']
>>> re.split(r'\Z',ss)
['owi\nweoifj\nfheu\n']
>>> re.split(r'$',ss)
['owi\nweoifj\nfheu\n']
>>> re.split(r'(?s)$',ss)
['owi\nweoifj\nfheu\n']
>>> re.split(r'(?m)(?s)$',ss)
['o