PHP html标签正则替换并可自定义正则规则
摘要:复制代码代码如下:
复制代码 代码如下:
<?php
function pregstring($str){
$strtemp = trim($str);
$search = array(
"|'|Uis",
"|<script[^>].*?</script>|Uis", // 去掉 javascript
"|[字定义].*[/字定义]|Uis", // 去掉缩略图
"|<[/!].*?[^<>]*?>|Uis", // 去掉 HTML 标记
"'>(quot|#34);'i", // 替换 HTML 实体
"'>(amp|#38);'i",
"|,|Uis",
"|[s]{2,}|is",
"[>nbsp;]isu",
"|[$]|Uis",
);
$replace = array(
"`",
"",
"",
"",
"",
"",
"",
" ",
" ",
" ",
);
$text = preg_replace($search, $replace, $strtemp);
return $text;
}
echo pregstring(字符串); //使用方法
?>
【PHP html标签正则替换并可自定义正则规则】相关文章:
★ PHP preg_replace() 正则替换所有符合条件的字符串
下一篇:
asp email邮箱地址验证正则表达式