Initial commit >= stub. Includes a hint. (#34036)

This commit is contained in:
James Liu
2018-12-20 17:12:29 -08:00
committed by Randell Dawson
parent f00c2e6730
commit ba50f794bb

View File

@ -3,8 +3,24 @@ title: Match Non-Whitespace Characters
---
## Match Non-Whitespace Characters
This is a stub. <a href='https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/javascript-algorithms-and-data-structures/regular-expressions/match-non-whitespace-characters/index.md' target='_blank' rel='nofollow'>Help our community expand it</a>.
## Hint 1
<a href='https://github.com/freecodecamp/guides/blob/master/README.md' target='_blank' rel='nofollow'>This quick style guide will help ensure your pull request gets accepted</a>.
* A global flag will help you get through this challenge.
<!-- The article goes here, in GitHub-flavored Markdown. Feel free to add YouTube videos, images, and CodePen/JSBin embeds -->
## Hint 2
* Try using a shorthand character for `S` non-whitespace.
# Spoiler Alert!! Solution Ahead!
## Solution
```
javascript
let sample = "Whitespace is important in separating words";
let countNonWhiteSpace = /\S/g; // Change this line
let result = sample.match(countNonWhiteSpace);
## Explanation
* The `\S` shorthand character is a shortcut for non-whitespace. The regular expresssion returns the number of characters that match it.