正则表达式 S 在 JavaScript 中是什么意思?

正则表达式中的/S/是什么意思?

while (cur ! = null) {
if (cur.nodeType == 3 && ! /\S/. test(cur.nodeValue)) {
element. removeChild(cur);
} else if (cur. nodeType == 1) {
cleanWhitespace(cur);
}
}
262647 次浏览

根据 这个参考\S匹配除了空格以外的任何东西。

当且仅当 string.Tab 和换行符作为空格计数时,/\S/.test(string)返回 true。

我相信它的意思是“除了空白字符之外的任何东西”。

\s匹配空格(空格、制表符和新行)。 \S被否定。

\s 元角色匹配空格字符。