]*)(?=>)/i","#", "Hello, click here to take a lookHello, click here to take a look"); ?&g"/> ]*)(?=>)/i","#", "Hello, click here to take a lookHello, click here to take a look"); ?&g">
Home >Backend Development >PHP Tutorial >http://www.12306.cn/mormhweb/ php regular filter html hyperlinks
echo preg_replace("/(?<=href=)([^>]*)(?=>)/i","#", "Hello, click here to take a lookHello, click here to take a look");
?>
Regular: /(?<=href=)([^>]*)(?=>)/
(?<=exp) matches the position after exp
(?=exp) matches the position before exp Position
This regular match matches all characters that are not ">" after href= and before ">"
Example:
Find these characters (url) and replace them with # , you can remove all links in html.
The above introduces the hyperlink of http://www.12306.cn/mormhweb/ php regular filtering html, including the content of http://www.12306.cn/mormhweb/. I hope that friends who are interested in PHP tutorials Helps.