【发布时间】:2012-05-23 17:26:10
【问题描述】:
喜欢PHP strip punctuation,但我想保留撇号。 示例:
I'm a student, but I don't like the school. I'll quit school.
strip 后面的字符串应该是:
I'm a student but I don't like the school I'll quit school
如何使用正则表达式或其他方式做到这一点?
【问题讨论】:
-
我试过 $string = preg_replace('/[^a-z0-9\']/', '', $string);好像没什么用。我的字符串来自一个 html 页面。撇号是 ’例如,Don't = Don’t