From 9a1b895002ed60e153ddc90b38e6b2cbde9d1436 Mon Sep 17 00:00:00 2001 From: greggubarev Date: Tue, 16 Oct 2018 01:53:35 +0400 Subject: [PATCH] Javascript: Added hint to Match Non-Whitespace Characters (#19243) * Javascript: Added hint to Match Non-Whitespace Characters Added hint to Match Non-Whitespace Characters (https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/match-non-whitespace-characters and https://guide.freecodecamp.org/certifications/javascript-algorithms-and-data-structures/regular-expressions/match-non-whitespace-characters/) * Replace match->matching * Fixed grammar --- .../match-non-whitespace-characters/index.md | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/client/src/guide/english/certifications/javascript-algorithms-and-data-structures/regular-expressions/match-non-whitespace-characters/index.md b/client/src/guide/english/certifications/javascript-algorithms-and-data-structures/regular-expressions/match-non-whitespace-characters/index.md index e813f5e018..06962d09bf 100644 --- a/client/src/guide/english/certifications/javascript-algorithms-and-data-structures/regular-expressions/match-non-whitespace-characters/index.md +++ b/client/src/guide/english/certifications/javascript-algorithms-and-data-structures/regular-expressions/match-non-whitespace-characters/index.md @@ -1,10 +1,20 @@ ---- -title: Match Non-Whitespace Characters ---- + ## Match Non-Whitespace Characters -This is a stub. Help our community expand it. - -This quick style guide will help ensure your pull request gets accepted. - + +## Problem: + +We need to change the regex ```countNonWhiteSpace``` to look for multiple non-whitespace characters in a string. + +## Solution: + +```js +let sample = "Whitespace is important in separating words"; +let countNonWhiteSpace = /\S/g; // Change this line +let result = sample.match(countNonWhiteSpace); +``` + +## Explanation: + +We use ```\S```, and this pattern will not match any of: whitespace, carriage return, tab, form feed, and new line characters. So we find all matching non-whitespace characters.