【发布时间】:2011-05-21 14:52:36
【问题描述】:
/\S/ 在正则表达式中是什么意思?
while (cur ! = null) {
if (cur.nodeType == 3 && ! /\S/. test(cur.nodeValue)) {
element. removeChild(cur);
} else if (cur. nodeType == 1) {
cleanWhitespace(cur);
}
}
【问题讨论】:
-
快速参考:
\s是shorthand 对应于[ \t\r\n\f],而\S相当于[^ \t\r\n\f]。 -
@caiosm1005 评论中括号之间的空格很重要。我浪费了太多时间没有意识到这一点。
标签: javascript regex