38

假设我想匹配“单词”字符 ( \w),但排除“_”,或者匹配空白字符 ( \s),但排除“\t”。我怎样才能做到这一点?

4

1 回答 1

61

使用包含 \W 或 \S 的否定类。

/[^\W_]/  # anything that's not a non-word character and not _
/[^\S\t]/ # anything that's not a non-space character and not \t
于 2010-08-23T15:21:10.517 回答