Determine whether a string contains a hyperlink
The code is as follows | |||||||||
if(preg_match("/]*>|/[^a]*a[^>]*>/i",$str))
else {
echo "The string has no hyperlink tag"; |
The code is as follows | |
echo preg_replace("/(?<=href=)([^>]*)(?=>)/i","#", " Hello, click here to take a lookHello, click here to take a look");
?>
|
代码如下 | |
function match_links($document) { preg_match_all("' 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; } |
(?=exp) matches the position before exp