How can I exclude some characters from a class?

前端 未结 1 1990
灰色年华
灰色年华 2020-11-30 06:18

Say I want to match a \"word\" character (\\w), but exclude \"_\", or match a whitespace character (\\s), but exclude \"\\t\". How can I do this? <

相关标签:
1条回答
  • 2020-11-30 06:59

    Use a negated class including \W or \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
    
    0 讨论(0)
提交回复
热议问题