I have this html tag:
x=""" <div>ad</div> \n\n <div> correct value </div> <div> wrong value </div> """
I want to get the corret value
so I search for the word ad
followed by </div>
then any thing until another <div>
then get all the values until </div>
I use this code:
re.findall(r'ad</div>.*<div>(.*)</div>',x,re.S)
I use the falg re.S because I want the dot to match new line also. I don't know How much lines there are between the divs. so i use .* !
I think findall should return correct value
, but it return wrong value
. why ? it search for the last div not the first one ?