Copy Code code as follows:
function Match_links ($document) {
Preg_match_all ("' <\s*a\s.*?href\s*=\s*" ([\)])? (1) (.*?) \\1| ([^\s\>]+)] [^>]*>? (.*?) </a> ' Isx ', $document, $links);
while (the list ($key, $val) = each ($links [2])) {
if (!empty ($val))
$match [' link '] = $val;
}
while (the list ($key, $val) = each ($links [3])) {
if (!empty ($val))
$match [' link '] = $val;
}
while (the list ($key, $val) = each ($links [4])) {
if (!empty ($val))
$match [' content '] = $val;
}
while (the list ($key, $val) = each ($links [0])) {
if (!empty ($val))
$match [' All '] [] = $val;
}
return $match;
}
The main problem is regular, the following gives a asp.net, multiple test regular
Get a link to a page regular
Copy Code code as follows:
public string gethref (string htmlcode)
{
String matchvale = "";
String Reg = @ "(h| H) (r| R) (e| E) (f| F) *= * (' | ")? ((\w|\\|\/|\.|:| -|_) +) (' | "" | *|>) ";
foreach (Match m in Regex.Matches (Htmlcode, Reg))
{
Matchvale = = (M.value). ToLower (). Replace ("href=", ""). Trim () + "| |";
}
Return matchvale;
}