Joh*_*ica 5

return preg_replace('/[\(\)\.\-\s,]/', '', $str);
Run Code Online (Sandbox Code Playgroud)

对于它的价值,大多数反斜杠是不必要的(用两种语言).括号和圆点不需要在字符类中进行转义.如果您愿意,可以将其简化为:

return preg_replace('/[().\-\s,]/', '', $str);
Run Code Online (Sandbox Code Playgroud)

  • 你可以将`-`移动到结尾:`/ [().\ s, - ] /` (2认同)