\s
, que é um s
minúsculo. Esse padrão não apenas corresponde ao espaço em branco, mas também ao retorno de carro, à guia, ao feed de formulário e aos novos caracteres de linha. Você pode pensar nisso como semelhante à classe de caracteres [ \r\t\f\n\v]
. let whiteSpace = "Espaço em branco. Espaço em branco em todo lugar!"
deixe spaceRegex = / \ s / g;
whiteSpace.match (spaceRegex);
// Retorna ["", ""]
countWhiteSpace
para procurar vários caracteres de espaço em branco em uma string. \s
to match all whitespace characters.");'
- text: Seu regex deve encontrar oito espaços em "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: 'Seu regex deve encontrar três espaços em "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: Seu regex não deve encontrar espaços em "MindYourPersonalSpace"
testString: 'assert("MindYourPersonalSpace".match(countWhiteSpace) == null, "Your regex should find no spaces in "MindYourPersonalSpace"
");'
```