Splitting on a regex w/o consuming delimiter
lars at larsshack.org
Sun Nov 11 07:28:09 CET 2001
Given a string such as:
sample = 'one two @three @four five @six'
I want to split it on the '@' character, but I want the '@' character to be
retained in each sequence. That is, I'd like the above string split into:
I thought maybe this would work:
Since, according to the python documentation, '(?=pattern)' matches
pattern without consuming anything. While it seemed like a good idea at
the time, it doesn't work.
Other than manually splitting the string, is there a more graceful
Lars Kellogg-Stedman <lars at larsshack.org> --> http://www.larsshack.org/
More information about the Python-list