如何从类中排除某些字符? [英] How can I exclude some characters from a class?
本文介绍了如何从类中排除某些字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我想匹配一个单词"字符(w
),但排除_",或者匹配一个空白字符(s
),但排除 ".我怎样才能做到这一点?
Say I want to match a "word" character (w
), but exclude "_", or match a whitespace character (s
), but exclude " ". How can I do this?
推荐答案
使用否定类,包括 W 或 S.
Use a negated class including W or S.
/[^W_]/ # anything that's not a non-word character and not _
/[^S ]/ # anything that's not a non-space character and not
这篇关于如何从类中排除某些字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文