I forgot to mention something else:
5) Don't try to parse html with your own regexes. There are plenty of perl HTML parsers that do the hard work for you. Here is one example:
use strict; use warnings; use 5.012; use HTML::TreeBuilder; my $string = <<END_OF_HTML; <ul> <li> <div id="Show1400"> <a href="../../../KeyboardKeys/RetainerClip/Acer/Aspire/1400">14 +00</a> </div> </li> <li> <div id="Show1410"> <a href="../../../KeyboardKeys/RetainerClip/Acer/Aspire/1410">14 +10</a> </div> </li> END_OF_HTML #Note the missing </ul> tag above. my $tree = HTML::TreeBuilder->new(); $tree->parse_content($string); my @links = $tree->look_down('_tag', 'a'); for my $link (@links) { say $link->attr('href'); } --output:-- ../../../KeyboardKeys/RetainerClip/Acer/Aspire/1400 ../../../KeyboardKeys/RetainerClip/Acer/Aspire/1410
The docs on how to use HTML::TreeBuilder are at HTML::Tree::Scanning.
In reply to Re: SOLVED:Regular expression fetching multiple matches
by 7stud
in thread SOLVED:Regular expression fetching multiple matches
by ansh batra
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |