Re: Negation in regular expressions

2006-09-08 Thread Ant
> >>> 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

Re: Negation in regular expressions

2006-09-08 Thread George Sakkis
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

Re: Negation in regular expressions

2006-09-08 Thread Ant
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

Re: Negation in regular expressions

2006-09-08 Thread Steve Holden
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

Re: Negation in regular expressions

2006-09-07 Thread Paddy
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

Re: Negation in regular expressions

2006-09-07 Thread Paddy
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

Negation in regular expressions

2006-09-07 Thread George Sakkis
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