【发布时间】:2012-02-05 21:30:45
【问题描述】:
我一直在使用以下正则表达式来替换字符串中的所有标点符号:
preg_replace('/[^\w\s]/', '', $tweet);
\w 是 [a-zA-Z0-9_] 的简写,\s 用于省略空格。我在这里学到了这种智慧:Strip punctuation in an address field in PHP。但是现在,我需要正则表达式来去除除
之外的所有字符a-z and A-Z
{ and }
所以它应该去掉所有的点、逗号、数字等。什么是正确的正则表达式?
【问题讨论】: