We would like to get the result
A HREF="index.html"However, note that the following code will retrieve more than that:
#!/usr/local/bin/perl my $html = "List of <A HREF=\"index.html\">Lecture Slides</A>."; $html =~ /<(.*)>/; print "$1\n";Result:
A HREF="index.html">Lecture Slides</A
In the example above, it matched all the text until the last > sign of the HTML text, and not until the closest one.
To force the quantifier to be lazy and capture the minimum it can before the rest of the regular expression, write a question mark ? after it.
$html =~ /<(.*?)>/;