1

Thank you for looking into my question.

I have this program:

import re

string="""
<img src="first" 
href="first" />
<img src="second" 
href="second" />
<img src="last" 
href="last" />
"""

src_pattern = "second"
fetch = re.compile(
    rf"<img.*{src_pattern}.*?/>",
    re.DOTALL
)

m=fetch.search(string)
print (m.group(0))

I am trying t get just

<img src="second" 
href="second" />

as the output. But when I run, I get

<img src="first" 
href="first" />
<img src="second" 
href="second" />

Any idea what am I missing?

wantro
  • 373
  • 1
  • 7
  • 18

0 Answers0