> ######################################
> import re
>
> s = 'xxxxxxx0'
>
> m = re.search("x*", s)
> print "First way", m.group(0)
>
> m = re.search("x*?", s)
> print "Second way", m.group(0)
> #####################################
> First way xxxxxxx
> Second way
>
> So now I'm really confused. It didn't do a non-greedy
> 'x' match, nor did it allow the '?' to match the '0'.
it did do a non-greedy match. It found as few "x"s as possible.
it found 0 of them, and quit. For a better test, use
s = '<tag 1><tag 2>'
print re.search('<tag.*?>',s).group(0)
print re.search('<tag.*>',s).group(0)
(the question/problem at hand)
-tkc
--
http://mail.python.org/mailman/listinfo/python-list