\s , которая является строчной s . Этот шаблон не только соответствует пробелу, но также возвращает карету, вкладку, форму и новые символы строки. Вы можете считать это похожим на класс символов [ \r\t\f\n\v] . let whiteSpace = "Пробел. Пробел везде!"
пусть пространство Regex = / \ s / g;
whiteSpace.match (spaceRegex);
// Возвращает ["", ""]
countWhiteSpace для поиска нескольких символов пробела в строке. \s to match all whitespace characters.");'
- text: Ваше регулярное выражение должно найти восемь пробелов в "Men are from Mars and women are from Venus."
testString: 'assert("Men are from Mars and women are from Venus.".match(countWhiteSpace).length == 8, "Your regex should find eight spaces in "Men are from Mars and women are from Venus."");'
- text: 'Ваше регулярное выражение должно найти три пробела в "Space: the final frontier."'
testString: 'assert("Space: the final frontier.".match(countWhiteSpace).length == 3, "Your regex should find three spaces in "Space: the final frontier."");'
- text: Ваше регулярное выражение не должно "MindYourPersonalSpace" пробелов в "MindYourPersonalSpace"
testString: 'assert("MindYourPersonalSpace".match(countWhiteSpace) == null, "Your regex should find no spaces in "MindYourPersonalSpace"");'
```