preg_replace 删除标点符号、空格和单词所有格形式?
$text =
"<tab><return><nbsp>O'Neil really
likes his pudding's, he really really does!!!1.5"
如果可能的话,我希望有这个,其中 '
是一个实际的制表符 \t
空间,而不是字面上的 '
>
$text = "O'Neil really likes his pudding he really really does 1.5"
删除白色步伐并用一个空格、标点符号替换它们,保留撇号后面的数字或任何不是 's' 的内容。
非常感谢!
$text =
"<tab><return><nbsp>O'Neil really
likes his pudding's, he really really does!!!1.5"
I would like to have this if possible where '<tab>'
is an actual tab \t
space not literally '<tab>'
$text = "O'Neil really likes his pudding he really really does 1.5"
removing the whites paces and replaces them with one space, the punctuation, keeping the numbers or anything after apostrophe thats not a 's'.
Thank you so much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先去掉
的
,然后用一个空格替换多个空格。最终它会删除前导和尾随空白。That first gets rid of
's
and then replaces multiple whitespace with one space. Eventually it removes leading and trailing whitespace.