Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想检查一个字符串是否有一些特殊字符并将它们删除。
如何添加反斜杠\和斜杠/和~|%*|',#来""检查所有特殊字符
\
/
~|%*|'
#
""
我需要类似的东西
preg_match('/\\\\/', $string);
你能帮助我吗?
谢谢
像这样试试
preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $string);
它可能会帮助你。
使用 preg_replace 并确保使用反斜杠转义点 (.) 等特殊字符。
然后你应该有类似的东西:
preg_replace('/[%\.&#-]/s', '', $String);