PHP regular filter HTML tags Spaces newline of the code of of attached instructions

  • 2020-03-31 21:21:07
  • OfStack

 
$str=preg_replace("/s+/", " ", $str); //Filter excess returns
$str=preg_replace("/<[ ]+/si","<",$str); //Filter <__ (" <" Number followed by space)

$str=preg_replace("/<!--.*?-->/si","",$str); //annotation
$str=preg_replace("/<(!.*?)>/si","",$str); //Filter the DOCTYPE
$str=preg_replace("/<(/?html.*?)>/si","",$str); //Filtering HTML tags
$str=preg_replace("/<(/?head.*?)>/si","",$str); //Filter head tag
$str=preg_replace("/<(/?meta.*?)>/si","",$str); //Filter meta tag
$str=preg_replace("/<(/?body.*?)>/si","",$str); //Filter the body tag
$str=preg_replace("/<(/?link.*?)>/si","",$str); //Filter link tag
$str=preg_replace("/<(/?form.*?)>/si","",$str); //Filter form tags
$str=preg_replace("/cookie/si","COOKIE",$str); //Filter COOKIE tags

$str=preg_replace("/<(applet.*?)>(.*?)<(/applet.*?)>/si","",$str); //Filter applet labels
$str=preg_replace("/<(/?applet.*?)>/si","",$str); //Filter applet labels

$str=preg_replace("/<(style.*?)>(.*?)<(/style.*?)>/si","",$str); //Filter style tag
$str=preg_replace("/<(/?style.*?)>/si","",$str); //Filter style tag

$str=preg_replace("/<(title.*?)>(.*?)<(/title.*?)>/si","",$str); //Filter the title tag
$str=preg_replace("/<(/?title.*?)>/si","",$str); //Filter the title tag

$str=preg_replace("/<(object.*?)>(.*?)<(/object.*?)>/si","",$str); //Filter object tag
$str=preg_replace("/<(/?objec.*?)>/si","",$str); //Filter object tag

$str=preg_replace("/<(noframes.*?)>(.*?)<(/noframes.*?)>/si","",$str); //Filter the noframes tags
$str=preg_replace("/<(/?noframes.*?)>/si","",$str); //Filter the noframes tags

$str=preg_replace("/<(i?frame.*?)>(.*?)<(/i?frame.*?)>/si","",$str); //Filter the frame tag
$str=preg_replace("/<(/?i?frame.*?)>/si","",$str); //Filter the frame tag

$str=preg_replace("/<(script.*?)>(.*?)<(/script.*?)>/si","",$str); //Filter script tag
$str=preg_replace("/<(/?script.*?)>/si","",$str); //Filter script tag
$str=preg_replace("/javascript/si","Javascript",$str); //Filter script tag
$str=preg_replace("/vbscript/si","Vbscript",$str); //Filter script tag
$str=preg_replace("/on([a-z]+)s*=/si","On\1=",$str); //Filter script tag
$str=preg_replace("/&#/si","& # ",$str); //Filter script tags, such as javAsCript:alert(

Related articles: