how to strip punctuation in php

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

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

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-01 23:00

    preg_replace("[^-\w\d\s\.=$'€%]",'',$subject)
    

    although it would be more correct and easy to specify the characters you want to strip, instead of characters (from an unknown set) you don't want to strip.

提交回复
热议问题