Capturar enlaces HREF
Publicado por José Ramon Martínez (2 intervenciones) el 10/03/2006 10:33:13
Buenos días,
Estoy trabajando en una función que, usando expresiones regulares, capture los enlaces (HREF) de un texto.
Alguien me podría ayudar a simplificarla?
gracias de antemano!!
sub getLinks
{
# crear hash
%hash = ();
for(@_){
while(/(<[^aA][^>]*>|[^<>]+)*<(A|a) (\w+=\"[^\"-]+\" )*((HREF|href)=\"([^\"]+)\")( [\w:;\(\)=\'\"-]*)*>(<[^aA][^>]*>|[^<>]+)*/g){
if ((! exists $hash{$6})&&($6!~/#\w+/)){
$hash{$6}= 1;
}
}<a href="http://XXX">
}
%hash;
}
Estoy trabajando en una función que, usando expresiones regulares, capture los enlaces (HREF) de un texto.
Alguien me podría ayudar a simplificarla?
gracias de antemano!!
sub getLinks
{
# crear hash
%hash = ();
for(@_){
while(/(<[^aA][^>]*>|[^<>]+)*<(A|a) (\w+=\"[^\"-]+\" )*((HREF|href)=\"([^\"]+)\")( [\w:;\(\)=\'\"-]*)*>(<[^aA][^>]*>|[^<>]+)*/g){
if ((! exists $hash{$6})&&($6!~/#\w+/)){
$hash{$6}= 1;
}
}<a href="http://XXX">
}
%hash;
}
Valora esta pregunta


0