in reply to regex not matching how I want it to :(

OMG I do not know what happened with my post formatting, sorry

while ( $line=~/<a href=\"(.*?)\.htm\">/ig ) {

on

<a href="test1.htm"> test1</a><br> <a href="test2.htm"> test2</a><br> <a href="test3.htm"> test3</a><br>

is matching

test1"> test1</a><br> <a href="test2

and not

test2

ok someone corrected my formatting in the original post, thank you