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:
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