Home > Backend Development > PHP Tutorial > PHP regular filtering html hyperlinks_PHP tutorial

PHP regular filtering html hyperlinks_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-21 15:46:45
Original
937 people have browsed it

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
This regular match matches all characters that are not ">" after href= and before ">"
Example:
Find these characters (url) and replace them with # to remove all links in the html.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320070.htmlTechArticle?php echo preg_replace("/(?=href=)([^]*)(?=)/ i","#", "a href='www.csdn.net'Hello, click here to take a look/aa href='www.jb51.net'Hello, click here to take a look/a"); ? Regular :/(?=href=)([^]*...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template