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.
我想在正则表达式中忽略 AZ、0-9 和空格,目前我有这个,它可以工作,但空格也被忽略,但我需要它们。
preg_match_all("/[^\w]/",$string,$matches);
\s表示空白字符。因此,如果您想匹配除单词字符 ( \w) 或空白字符 ( \s) 之外的每个字符,请尝试以下操作:
\s
\w
preg_match_all("/[^\w\s]/",$string,$matches);