如何删除非字母数字字符? [英] How to remove non-alphanumeric characters?
本文介绍了如何删除非字母数字字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要从字符串中删除所有不在a-z A-Z 0-9
集中或不包含空格的字符.
I need to remove all characters from a string which aren't in a-z A-Z 0-9
set or are not spaces.
有人能做到这一点吗?
推荐答案
听起来像您几乎已经知道您想做的一样,您基本上将其定义为正则表达式.
Sounds like you almost knew what you wanted to do already, you basically defined it as a regex.
preg_replace("/[^A-Za-z0-9 ]/", '', $string);
这篇关于如何删除非字母数字字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文