Wednesday, 28 August 2013

Perl Regular Expression to extract value from nested html tags

Perl Regular Expression to extract value from nested html tags

$match = q(<a href="#google"><h1><b>Google</b></h1></a>);
if($match =~ /<a.*?href.*?><.?>(.*?)<\/a>/){
$title = $1;
}else {
$title="";
}
print"$title";
OUTPUT: Google</b></h1>
It Should be : Google
Unable to extract value from link using Regex in Perl, it could have one
more or less nesting:
<h1><b><i>Google</i></b></h1>

No comments:

Post a Comment