正则表达式中的/S/是什么意思?
while (cur ! = null) { if (cur.nodeType == 3 && ! /\S/. test(cur.nodeValue)) { element. removeChild(cur); } else if (cur. nodeType == 1) { cleanWhitespace(cur); } }
根据 这个参考,\S匹配除了空格以外的任何东西。
\S
当且仅当 string.Tab 和换行符作为空格计数时,/\S/.test(string)返回 true。
string
/\S/.test(string)
我相信它的意思是“除了空白字符之外的任何东西”。
\s匹配空格(空格、制表符和新行)。 \S被否定。
\s
\s 元角色匹配空格字符。