how to strip punctuation in php

后端 未结 6 1398
长发绾君心
长发绾君心 2021-02-01 22:45

How can I strip punctuation except for these characters . = $ \' - %

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-01 23:03

    Try:

    preg_replace("/[^\w-\p{L}\p{N}\p{Pd}\$\.€%']/", "", 'YOUR DATA');

    You didn't mentioned if you wanted spaces or not, so that will strip that too.

提交回复
热议问题