查找以 @ 开头且包含除正则表达式中的空格之外的所有字符的单词


find all words that begin with @ and that contain all chars except for spaces in regex

标题说明了一切。

这是我所拥有的:

preg_match_all("/@['w_.]+/",$text_tbh, $matches);

但这不包括带有特殊字符的单词。

谢谢

使用与任何非空格字符匹配的'S

preg_match_all('/@'S+/', $text_tbh, $matches);

你抱怨什么特殊的字符?将它们包含在括号中!

preg_match_all("/@['w._#?!+]+/",$text_tbh, $matches);