2018-10-10 18:03:03 -04:00
---
id: 587d7db9367417b2b2512ba4
title: Match Non-Whitespace Characters
challengeType: 1
2019-08-28 16:26:13 +03:00
forumTopicId: 18210
2018-10-10 18:03:03 -04:00
localeTitle: Совпадение символов без пробелов
---
## Description
2019-08-28 16:26:13 +03:00
<section id='description'>
Вы узнали о поиске пробельных с помощью <code>\s</code> , с о строчной <code>s</code> . Вы также можете искать все, кроме пробелов. Поиск непробельных с помощью <code>\S</code> , который является прописной <code>s</code> . Этот шаблон не будет соответствовать пробелам, возврату каретки, вкладке, фиду формы и новым строковым символам. Вы можете думать, что это похоже на класс символов <code>[^ \r\t\f\n\v]</code> . <blockquote> let whiteSpace = "Пробел. Пробел везде!" <br> пусть nonSpaceRegex = / \ S / g; <br> whiteSpace.match (nonSpaceRegex) .length; // Возвращает 32 </blockquote>
</section>
2018-10-10 18:03:03 -04:00
## Instructions
2019-08-28 16:26:13 +03:00
<section id='instructions'>
Измените регулярное выражение <code>countNonWhiteSpace</code> чтобы искать несколько небелых символов в строке.
</section>
2018-10-10 18:03:03 -04:00
## Tests
<section id='tests'>
```yml
tests:
2019-08-28 16:26:13 +03:00
- text: Your regex should use the global flag.
testString: assert(countNonWhiteSpace.global);
- text: Your regex should use the shorthand character <code>\S/code> to match all non-whitespace characters.
testString: assert(/\\S/.test(countNonWhiteSpace.source));
- text: Your regex should find 35 non-spaces in <code>"Men are from Mars and women are from Venus."</code>
testString: assert("Men are from Mars and women are from Venus.".match(countNonWhiteSpace).length == 35);
- text: 'Your regex should find 23 non-spaces in <code>"Space: the final frontier."</code>'
testString: 'assert("Space: the final frontier.".match(countNonWhiteSpace).length == 23);'
- text: Your regex should find 21 non-spaces in <code>"MindYourPersonalSpace"</code>
testString: assert("MindYourPersonalSpace".match(countNonWhiteSpace).length == 21);
2018-10-10 18:03:03 -04:00
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
let sample = "Whitespace is important in separating words";
let countNonWhiteSpace = /change/; // Change this line
let result = sample.match(countNonWhiteSpace);
```
</div>
</section>
## Solution
<section id='solution'>
```js
2019-08-28 16:26:13 +03:00
let sample = "Whitespace is important in separating words";
let countNonWhiteSpace = /\S/g; // Change this line
let result = sample.match(countNonWhiteSpace);
2018-10-10 18:03:03 -04:00
```
2019-08-28 16:26:13 +03:00
2018-10-10 18:03:03 -04:00
</section>