标签: regex perl character-class
假设我要匹配“字”字符(\w),但要排除“_”,或匹配空白字符(\s),但要排除“\ t”。我怎样才能做到这一点?
\w
\s
答案 0 :(得分:42)
使用包含\ 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