string split without consumption

Tim Chase python.list at tim.thechases.com
Sat Feb 2 08:22:54 EST 2008


> 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







More information about the Python-list mailing list