PHP html tag regular replacement and customizable regular rules

高洛峰
Release: 2023-03-05 06:46:02
Original
1431 people have browsed it

<?php 
function pregstring($str){ 
$strtemp = trim($str); 
$search = array( 
"|&#39;|Uis", 
"|<script[^>].*?</script>|Uis", // 去掉 javascript 
"|\[字定义\].*\[/字定义\]|Uis", // 去掉缩略图 
"|<[\/\!].*?[^<>]*?>|Uis", // 去掉 HTML 标记 
"&#39;>(quot|#34);&#39;i", // 替换 HTML 实体 
"&#39;>(amp|#38);&#39;i", 
"|,|Uis", 
"|[\s]{2,}|is", 
"[>nbsp;]isu", 
"|[$]|Uis", 
); 
$replace = array( 
"`", 
"", 
"", 
"", 
"", 
"", 
"", 
" ", 
" ", 
" ", 
); 
$text = preg_replace($search, $replace, $strtemp); 
return $text; 
} 
echo pregstring(字符串); //使用方法 
?>
Copy after login

For more articles related to PHP html tag regular replacement and customizable regular rules, please pay attention to the PHP Chinese website!

Related labels:
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template