* fix: remove isHidden flag from frontmatter * fix: add isUpcomingChange Co-authored-by: Ahmad Abdolsaheb <ahmad.abdolsaheb@gmail.com> * feat: hide blocks not challenges Co-authored-by: Ahmad Abdolsaheb <ahmad.abdolsaheb@gmail.com> Co-authored-by: Ahmad Abdolsaheb <ahmad.abdolsaheb@gmail.com>
2.2 KiB
2.2 KiB
id, title, challengeType, forumTopicId
id | title | challengeType | forumTopicId |
---|---|---|---|
587d7db8367417b2b2512ba3 | Match Whitespace | 1 | 301359 |
Description
\s
, which is a lowercase s
. This pattern not only matches whitespace, but also carriage return, tab, form feed, and new line characters. You can think of it as similar to the character class [ \r\t\f\n\v]
.
let whiteSpace = "Whitespace. Whitespace everywhere!"
let spaceRegex = /\s/g;
whiteSpace.match(spaceRegex);
// Returns [" ", " "]
Instructions
countWhiteSpace
to look for multiple whitespace characters in a string.
Tests
tests:
- text: Your regex should use the global flag.
testString: assert(countWhiteSpace.global);
- text: Your regex should use the shorthand character <code>\s</code> to match all whitespace characters.
testString: assert(/\\s/.test(countWhiteSpace.source));
- text: Your regex should find eight 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(countWhiteSpace).length == 8);
- text: 'Your regex should find three spaces in <code>"Space: the final frontier."</code>'
testString: 'assert("Space: the final frontier.".match(countWhiteSpace).length == 3);'
- text: Your regex should find no spaces in <code>"MindYourPersonalSpace"</code>
testString: assert("MindYourPersonalSpace".match(countWhiteSpace) == null);
Challenge Seed
let sample = "Whitespace is important in separating words";
let countWhiteSpace = /change/; // Change this line
let result = sample.match(countWhiteSpace);
Solution
let sample = "Whitespace is important in separating words";
let countWhiteSpace = /\s/g;
let result = sample.match(countWhiteSpace);