[Python-Dev] Re: Some questions about maintenance of the regular expression
code.
A.M. Kuchling
amk@amk.ca
Wed, 26 Feb 2003 13:34:34 -0500
M.-A. Lemburg wrote:
> Hmm, could you explain where ".*?" is useful ?
The most common example comes from writing a regex to match bits of
HTML. If you have a pattern like this:
<a href="([^"]*)"> (.*) </a>
and your input text is
<a href="a">blah</a> <a href="b">blah</a>,
group 2 in the pattern will match 'blah</a> <a href="b">blah', which is
not the link text that you want. If you write .*?,
then group 2 matches just "blah", which is more useful.
--amk (www.amk.ca)
Ominous, isn't it?
-- The Doctor, in "The Awakening"