Home  >  Article  >  Backend Development  >  How to remove special letters in php regular expression

How to remove special letters in php regular expression

藏色散人
藏色散人Original
2021-12-28 09:19:141662browse

php正则实现去掉特殊字母的方法:1、创建一个PHP示例文件;2、通过“$str = preg_replace($ddd,'',$str);”去除特殊字符即可。

How to remove special letters in php regular expression

本文操作环境:Windows7系统,PHP7.1版,Dell G3电脑。

php正则怎么实现去掉特殊字母?

php 正则去除中文,汉字,特殊字符

 正则去除中文,汉字,特殊字符:

$str = '  432.65456787rewqrewq6我的撒    ';
$ddd = "/[ &#39;,:;*?~`!@#$%^&+=)(<>{}]|\]|\[|\/|\\\|\"|\|/";
$cc = &#39;/[\x80-\xff]{0,}/&#39;;
$qq = "/[a-zA-Z]+/";
$str = preg_replace($ddd,&#39;&#39;,$str);
$str = preg_replace($qq,&#39;&#39;,$str);
$str = preg_replace($cc,&#39;&#39;,$str);
echo $str;

推荐学习:《PHP视频教程

The above is the detailed content of How to remove special letters in php regular expression. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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