\s
, com um s
minúsculo. Você também pode pesquisar tudo, exceto o espaço em branco. Procure por espaços não brancos usando \S
, que é um s
maiúsculo. Esse padrão não corresponderá a espaço em branco, retorno de carro, guia, feed de formulário e novos caracteres de linha. Você pode pensar que é semelhante à classe de caracteres [^ \r\t\f\n\v]
. let whiteSpace = "Espaço em branco. Espaço em branco em todo lugar!"
deixe nonSpaceRegex = / \ S / g;
whiteSpace.match (nonSpaceRegex) .length; // retorna 32
countNonWhiteSpace
da regex para procurar vários caracteres que não sejam espaços em branco em uma string. \S/code> to match all non-whitespace characters.");'
- text: Seu regex deve encontrar 35 não-espaços em "Men are from Mars and women are from Venus."
testString: 'assert("Men are from Mars and women are from Venus.".match(countNonWhiteSpace).length == 35, "Your regex should find 35 non-spaces in "Men are from Mars and women are from Venus."
");'
- text: 'Seu regex deve encontrar 23 espaços diferentes em "Space: the final frontier."
'
testString: 'assert("Space: the final frontier.".match(countNonWhiteSpace).length == 23, "Your regex should find 23 non-spaces in "Space: the final frontier."
");'
- text: Seu regex deve encontrar 21 não espaços em "MindYourPersonalSpace"
testString: 'assert("MindYourPersonalSpace".match(countNonWhiteSpace).length == 21, "Your regex should find 21 non-spaces in "MindYourPersonalSpace"
");'
```