Only the 4th test case works.
first m~href="(.*?)"~s This will match the first href inside your line and grab what's between the quotes, like this: /hoh/hoh/hoh/hoh/hoh
Second: m~href="(.*?)".*>lol~s This will match the first href inside your line and grab whatever is between quotes, and then match any number of characters until it finds >lol like this: /hoh/hoh/hoh/hoh/hoh
Try to take .* With m~href="(.*?)"(.*)>lol~s
$1 contains : /hoh/hoh/hoh/hoh/hoh $2 contains : class="hoh">hoh</a> <a href="/foo/foo/foo/foo/foo" class="foo">foo </a> <a href="/bar/bar/bar/bar/bar" class="bar">bar</a> <a href="/lol/lol/lol/lol/lol" class="lol"
third: m~href="(.*?)".*?>lol~s The same result as the previous test example.
Fourth: m~.*href="(.*?)".*?>lol~s This will match any number of any character, then href=" , and then commit any number of characters that are not greedy for a quote, and then match any number of characters until it finds >lol like this: /lol/lol/lol/lol/lol
Try to capture everything .* With m~(.*)href="(.*?)"(.*?)>lol~s
$1 contains : <a href="/hoh/hoh/hoh/hoh/hoh" class="hoh">hoh</a> <a href="/foo/foo/foo/foo/foo" class="foo">foo </a> <a href="/bar/bar/bar/bar/bar" class="bar">bar</a> <a $2 contains : /lol/lol/lol/lol/lol $3 contains : class="lol"
Check out this site for an explanation of what your regular expressions do.
Toto source share