We would like to get the result
A HREF="assignment6.html"However, note that the following code will retrieve more than that:
#!/usr/bin/perl my $html = "<A HREF=\"http://tarshish/md/biu/ac/il/assignment6.html\"> Assignment 6 </A>."; $html =~ /<(.*)>/; print "$1\n";Result:
A HREF="http://tarshish.md.biu.ac.il/assignment6.html"> Assignment 6 </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 "grab" the minimum it can before the rest of the regular expression, write a question mark ? after it.
$html =~ /<(.*?)>/;Result: