Just modify the style names in the qr'ed regex and use it.#!usr/bin/perl my $html = <<'HTML'; <li><a class="style5" href="http://www.site.com/page.html"> some words here</a> - <a class="style3" href="http://www.site.com/page2.html"> "some words here"</a> </li> HTML my $regex = qr{ <a \s+ class\s*=\s*"style5" \s+ href\s*=\s*[\"\'] [^\"\']+ [\"\']\s*> #first href (not c +aptured) \s*([^<>]+?)\s* #text inside first <a></a> +(captured) </a>\s* -\s* <a \s+ class\s*=\s*"style3" \s+ href\s*=\s*[\"\'] ([^\"\']+) [\"\']\s*> #second href (not +captured) \s*([^<>]+?)\s* #text inside second <a></a> + (captured) </a> }xi; $html =~ /$regex/; print join "\n", $1, $2, $3, "";
But if you want something more than a one-time solution for a very certain case, it'll be better to study HTML parsing modules mentioned in the comment above.
In reply to Re: 3 capture multi line regex
by Ieronim
in thread 3 capture multi line regex
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |