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_replace 并对其进行更改,使其也允许_、&和#'s(下划线、& 和磅)?
_
&
#
preg_replace("/[^A-Za-z0-9 ]/", '', $string)
谢谢!!
这很容易...
preg_replace("/[^\w#& ]/")
\w字符类包括[A-Za-z0-9_].
\w
[A-Za-z0-9_]
preg_replace("/[^A-Za-z0-9_&#]/")