> >>> re.split(r'@#', s)
> ['', ' This ', ' is a ', '', ' test ']
> >>> [g.group(1) for g in re.finditer(r'(.*?)(?:@#|$)', s)]
> ['', ' This ', ' is a ', '', ' test ', '']
If it's duplicating the behaviour of split, but returning an iterator
instead, how about avoiding hacking around with messy re
Paddy wrote:
> George Sakkis wrote:
> > It's always striked me as odd that you can express negation of a single
> > character in regexps, but not any more complex expression. Is there a
> > general way around this shortcoming ? Here's an example to illustrate a
> > use case:
> >
> > >>> import re
Steve Holden wrote:
> George Sakkis wrote:
> > It's always striked me as odd that you can express negation of a single
> > character in regexps, but not any more complex expression. Is there a
> > general way around this shortcoming ?
The whole point of regexes is that they define expressions to
George Sakkis wrote:
> It's always striked me as odd that you can express negation of a single
> character in regexps, but not any more complex expression. Is there a
> general way around this shortcoming ? Here's an example to illustrate a
> use case:
>
>
import re
>
> # split with '@' as d
Paddy wrote:
> George Sakkis wrote:
> > It's always striked me as odd that you can express negation of a single
> > character in regexps, but not any more complex expression. Is there a
> > general way around this shortcoming ? Here's an example to illustrate a
> > use case:
> >
> > >>> import re
George Sakkis wrote:
> It's always striked me as odd that you can express negation of a single
> character in regexps, but not any more complex expression. Is there a
> general way around this shortcoming ? Here's an example to illustrate a
> use case:
>
> >>> import re
> # split with '@' as delim
It's always striked me as odd that you can express negation of a single
character in regexps, but not any more complex expression. Is there a
general way around this shortcoming ? Here's an example to illustrate a
use case:
>>> import re
# split with '@' as delimiter
>>> [g.group() for g in re.fin