「php」正規表現(preg_replace)を使ってhtmlタグ、スペース、改行を置換する方法

phpコード
$str=preg_replace(“/\s+/", " “, $str); //スペース
$str=preg_replace(“/<[ ]+/si","<“,$str); //<__
$str=preg_replace(“/<\!–.*?–>/si","",$str); //コメント
$str=preg_replace(“/<(\!.*?)>/si","",$str); //DOCTYPE
$str=preg_replace(“/<(\/?html.*?)>/si","",$str); //htmlタグ
$str=preg_replace(“/<(\/?head.*?)>/si","",$str); //headタグ
$str=preg_replace(“/<(\/?meta.*?)>/si","",$str); //metaタグ
$str=preg_replace(“/<(\/?body.*?)>/si","",$str); //bodyタグ
$str=preg_replace(“/<(\/?link.*?)>/si","",$str); //linkタグ
$str=preg_replace(“/<(\/?form.*?)>/si","",$str); //formタグ
$str=preg_replace(“/cookie/si","COOKIE",$str); //COOKIEタグ
$str=preg_replace(“/<(applet.*?)>(.*?)<(\/applet.*?)>/si","",$str); //appletタグ
$str=preg_replace(“/<(\/?applet.*?)>/si","",$str); //appletタグ
$str=preg_replace(“/<(style.*?)>(.*?)<(\/style.*?)>/si","",$str); //styleタグ
$str=preg_replace(“/<(\/?style.*?)>/si","",$str); //styleタグ
$str=preg_replace(“/<(title.*?)>(.*?)<(\/title.*?)>/si","",$str); //titleタグ
$str=preg_replace(“/<(\/?title.*?)>/si","",$str); //titleタグ
$str=preg_replace(“/<(object.*?)>(.*?)<(\/object.*?)>/si","",$str); //objectタグ
$str=preg_replace(“/<(\/?objec.*?)>/si","",$str); //objectタグ
$str=preg_replace(“/<(noframes.*?)>(.*?)<(\/noframes.*?)>/si","",$str); //noframesタグ
$str=preg_replace(“/<(\/?noframes.*?)>/si","",$str); //noframesタグ
$str=preg_replace(“/<(i?frame.*?)>(.*?)<(\/i?frame.*?)>/si","",$str); //frameタグ
$str=preg_replace(“/<(\/?i?frame.*?)>/si","",$str); //frameタグ
$str=preg_replace(“/<(script.*?)>(.*?)<(\/script.*?)>/si","",$str); //scriptタグ
$str=preg_replace(“/<(\/?script.*?)>/si","",$str); //scriptタグ
$str=preg_replace(“/javascript/si","Javascript",$str); //scriptタグ
$str=preg_replace(“/vbscript/si","Vbscript",$str); //scriptタグ
$str=preg_replace(“/on([a-z]+)\s*=/si","On\\1=",$str); //scriptタグ
$str=preg_replace(“/&#/si","&#",$str); //scriptタグ,javascript:alert(

PHP

Posted by arkgame