Home >Backend Development >PHP Problem >How to remove special letters in php regular expression
php正则实现去掉特殊字母的方法:1、创建一个PHP示例文件;2、通过“$str = preg_replace($ddd,'',$str);”去除特殊字符即可。
本文操作环境:Windows7系统,PHP7.1版,Dell G3电脑。
php正则怎么实现去掉特殊字母?
php 正则去除中文,汉字,特殊字符
正则去除中文,汉字,特殊字符:
$str = ' 432.65456787rewqrewq6我的撒 '; $ddd = "/[ ',:;*?~`!@#$%^&+=)(<>{}]|\]|\[|\/|\\\|\"|\|/"; $cc = '/[\x80-\xff]{0,}/'; $qq = "/[a-zA-Z]+/"; $str = preg_replace($ddd,'',$str); $str = preg_replace($qq,'',$str); $str = preg_replace($cc,'',$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!