Home >Backend Development >PHP Tutorial >PHP regular filtering html hyperlinks_PHP tutorial
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.