What does /\S/ mean in a regex?
regex中的/\S/是什么意思?
while (cur ! = null) {
if (cur.nodeType == 3 && ! /\S/. test(cur.nodeValue)) {
element. removeChild(cur);
} else if (cur. nodeType == 1) {
cleanWhitespace(cur);
}
}
5 个解决方案
#1
116
\s
matches whitespace (spaces, tabs and new lines). \S
is negated \s
.
\s匹配空格(空格、制表符和新行)。\ S是否定\ S。
#3
13
I believe it means 'anything but a whitespace character'.
我相信它的意思是“除了空白字符之外的任何东西”。
#4
6
/\S/.test(string)
returns true if and only if there's a non-space character in string
. Tab and newline count as spaces.
/\S/.test(string)当且仅当字符串中有非空格字符时返回true。制表符和换行符计数为空格。
#5
6
The \s metacharacter is used to find a whitespace character.
\s元字符用于查找空格字符。
#1
116
\s
matches whitespace (spaces, tabs and new lines). \S
is negated \s
.
\s匹配空格(空格、制表符和新行)。\ S是否定\ S。
#2
#3
13
I believe it means 'anything but a whitespace character'.
我相信它的意思是“除了空白字符之外的任何东西”。
#4
6
/\S/.test(string)
returns true if and only if there's a non-space character in string
. Tab and newline count as spaces.
/\S/.test(string)当且仅当字符串中有非空格字符时返回true。制表符和换行符计数为空格。
#5
6
The \s metacharacter is used to find a whitespace character.
\s元字符用于查找空格字符。