The easiest way to filter links is to use the Strip_tags function of the PHP tutorial, as follows
PHP Filter HTML function: Strip_tags (string) so that you can filter out all the HTML tags.
If you want to filter out all HTML tags except the , you can write this: Strip_tags (String, "Filter all HTML tags except <p>xxx</p><b></b>,
You can write this:
strip_tags (String, "<p><b>");
The above procedure is not advisable, because it filters all the HTML, so we just filter the connection part.
<?php
echo preg_replace ("/<=href=) ([^>]*) (?=>)/I", "#", "<a href= ' www.111cn.net ' > Hello, click here to see </a>< A href= ' www.111cn.net ' > Hello, click here to see </a> ');
?>
Regular:/(? <=href=) ([^>]*) (?=>)/
(? <=exp) matches the position of the exp rear
(? =exp) match the position of the exp front
This matches all characters that are not ">" before ">" After href=
Example: <a href= ' www.111cn.net ' >
To upgrade, we only filter the links of other sites to save their own site
$str = ' <li><a href= ' http://www.111cn.net/12345s ' target= ' _blank ' > Swarovski! </a></li><li><a href=http://123.com/n.php?a=luxury& target= "_blank" > F Joe </a>< /li><li><a href= "http://mb.111cn.net/" target= "_blank" > F clothing;
$match = '/<li><ashref= ' http://[w.] "*123.com/[w]+.php?a=*[w&=]*" s+target= "_blank" > (. *) </a></li>/isu ';
Preg_match_all ($match, $str, $arr);
echo "<pre>";
Print_r ($arr [0]);
echo "</pre>";
For more details please see: http://www.111cn.net/phper/php/35063.htm