PHP完美的提取链接正则

function match_links( $document ) {    
preg_match_all( "'<\s*a\s.*?href\s*=\s*([\"\'])?(?(1)(.*?)\\1|([^\s\>]+))[^>]*>?(.*?)'isx" , $document , $links );                         while (list( $key , $val ) = each( $links [2])) { if (! empty ( $val )) $match [ 'link' ][] = $val ;
} while (list( $key , $val ) = each( $links [3])) { if (! empty ( $val )) $match [ 'link' ][] = $val ;
}         while (list( $key , $val ) = each( $links [4])) { if (! empty ( $val )) $match [ 'content' ][] = $val ;
} while (list( $key , $val ) = each( $links [0])) { if (! empty ( $val )) $match [ 'all' ][] = $val ;
}                 return $match ;
}

你可能感兴趣的:(PHP完美的提取链接正则)