/\S/在正则表达式中代表什么意思?
while (cur ! = null) {
if (cur.nodeType == 3 && ! /\S/. test(cur.nodeValue)) {
element. removeChild(cur);
} else if (cur. nodeType == 1) {
cleanWhitespace(cur);
}
}
/\S/在正则表达式中代表什么意思?
while (cur ! = null) {
if (cur.nodeType == 3 && ! /\S/. test(cur.nodeValue)) {
element. removeChild(cur);
} else if (cur. nodeType == 1) {
cleanWhitespace(cur);
}
}
\s
匹配空白字符(空格、制表符和换行符)。\S
是 \s
的反义。
\S
匹配任何非空格字符,根据这个参考链接。
S
,以便将其与大写字母"S"区分开来。 - instantsetsuna我认为它的意思是“除了空格字符以外的任何字符”。
/\S/.test(string)
只有在 string
中存在非空格字符时才返回 true。制表符和换行符被视为空格。
\s
是一个简写,表示[ \t\r\n\f]
,而\S
等同于[^ \t\r\n\f]
。 - caiosm1005