ungreedy regular expressions

Andrew M. Kuchling akuchlin at mems-exchange.org
Wed Apr 26 17:10:21 EDT 2000


Michael Hudson <mwh21 at cam.ac.uk> writes:
> ckotso at cs.ntua.gr (Constantinos A. Kotsokalis) writes:
> > I recently added two lines of code to the python distribution, in order
> > to support ungreedy regular expressions (which are supported by pcre
>
> Aren't the *?,+? patterns "ungreedy"?

Yes, but the PCRE_UNGREEDY flag turns the syntax around, so * is
ungreedy and *? is greedy.  It's useful for applications where a naive
user might be entering regexes, since naive expectations usually don't
match the default greedy behaviour.

Unfortunately, the PCRE module is probably not going to be used in
Python 1.6, so applying the patch isn't likely to be very useful.
I'll think about it a bit.

-- 
A.M. Kuchling			http://starship.python.net/crew/amk/
When one has stopped loving somebody, one feels that he has become someone
else, even though he is still the same person.
  -- Sei Shonagon, _The Pillow Book_



More information about the Python-list mailing list