I am experimenting with for regex lazy matches
.
when I tried this:
>>> text='<em>Hello <>World</em>'
>>> pattern3=re.compile('<.*?>')
>>> for mat in re.findall(pattern3,text):
... print mat
...
<em>
<>
</em>
It works as expected, and gives the three matches that are possible but when I tried this:
>>> text="1011"
>>> pattern1=re.compile('1.*?1')
>>> for mat in re.findall(pattern1,text):
... print mat
...
101
I get only one output, but I should get 101 and 11
, why 11
is not being matched.
my regex '1.*?1'
looks for 1
followed by zero or more of anything and a 1
again.