Splitting on a regex w/o consuming delimiter  Lemniscate
d_blade8 at hotmail.com Mon Nov 12 06:39:59 CET 2001  Nadav
Horesh <Nadavh at envision.co.il> wrote in message
news:<mailman.1005469891.21795.python-list at python.org>... >
Whats about: >  >>> st = 'This @is a @modul@ ar trr' >  >>>
re.split(".(?=@)", st) > ['This', '@is a', '@modu', '@ ar trr']
> Nadav.  Actually, I like this one, and you can do it an
infinite number of ways (take a look at <i> Mastering Regular
Expressions </i> by O'Reilly for a better idea of why using
regular expressions can be tricky (like trying to split
something and losing what you split).  Personally, I would go
like the above, but let's try something else, like maybe (and
you can hide this in a function, I just do it here  xl = []
while st.find('@') != -1:      st = st[:st.rfind('@')] print xl
['This ', '@is a ', '@modul', '@ ar trr']  Put something like it
into a function/class (depending on what you need to do with the
results, I guess).  Maybe pass in two parameters, a str