如何删除非字母数字字符?
问题描述:
我需要从字符串中删除所有不在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);