Re: re.match -- not greedy?

2006-11-22 Thread Ant
EXI-Andrews, Jack wrote: the '*' and '+' don't seem to be greedy.. they will consume less in order to match a string: import re;re.match('(a+)(ab)','aaab').groups() ('aa', 'ab') this is the sort of behaviour i'd expect from '(a+?)(ab)' a+ should greedily consume a's at the expense

re.match -- not greedy?

2006-11-21 Thread EXI-Andrews, Jack
I wrote: import re;re.match('(a+)(ab)','aaab').groups() ('aa', 'ab') this is the sort of behaviour i'd expect from '(a+?)(ab)' a+ should greedily consume a's at the expense of the string not matching Fredrick wrote: that's a misunderstanding of what a regular expression is,

Re: re.match -- not greedy?

2006-11-21 Thread Fredrik Lundh
EXI-Andrews, Jack wrote: that's a misunderstanding of what a regular expression is, though: conceptually, a RE describes a set of strings, and the RE engine is designed to answer the question does this string belong to this set. if that's so, what is the point of +? and *? (?)

re.match -- not greedy?

2006-11-19 Thread EXI-Andrews, Jack
the '*' and '+' don't seem to be greedy.. they will consume less in order to match a string: import re;re.match('(a+)(ab)','aaab').groups() ('aa', 'ab') this is the sort of behaviour i'd expect from '(a+?)(ab)' a+ should greedily consume a's at the expense of the string not matching in

Re: re.match -- not greedy?

2006-11-19 Thread Carl Banks
EXI-Andrews, Jack wrote: the '*' and '+' don't seem to be greedy.. they will consume less in order to match a string: import re;re.match('(a+)(ab)','aaab').groups() ('aa', 'ab') this is the sort of behaviour i'd expect from '(a+?)(ab)' a+ should greedily consume a's at the expense of

Re: re.match -- not greedy?

2006-11-19 Thread André Malo
* Carl Banks wrote: I'm suddenly curious if there are any cases at all where greediness changes whether it finds a match. nope, per definitionem ;-) greedy := longest leftmost match nd -- die (eval q-qq[Just Another Perl Hacker ] ;-) # André Malo, http://www.perlig.de/ # --

Re: re.match -- not greedy?

2006-11-19 Thread Noah Rawlins
Carl Banks wrote: EXI-Andrews, Jack wrote: the '*' and '+' don't seem to be greedy.. they will consume less in order to match a string: import re;re.match('(a+)(ab)','aaab').groups() ('aa', 'ab') this is the sort of behaviour i'd expect from '(a+?)(ab)' a+ should greedily consume a's