.github
api-server
client
config
curriculum
challenges
01-responsive-web-design
02-javascript-algorithms-and-data-structures
basic-algorithm-scripting
basic-data-structures
basic-javascript
debugging
es6
functional-programming
intermediate-algorithm-scripting
javascript-algorithms-and-data-structures-projects
object-oriented-programming
regular-expressions
Check for All or None.md
Extract Matches.md
Find Characters with Lazy Matching.md
Find More Than the First Match.md
Find One or More Criminals in a Hunt.md
Ignore Case While Matching.md
Match All Letters and Numbers.md
Match All Non-Numbers.md
Match All Numbers.md
Match Anything with Wildcard Period.md
Match Beginning String Patterns.md
Match Characters that Occur One or More Times.md
Match Characters that Occur Zero or More Times.md
Match Ending String Patterns.md
Match Everything But Letters and Numbers.md
Match Letters of the Alphabet.md
Match Literal Strings.md
Match Non-Whitespace Characters.md
Match Numbers and Letters of the Alphabet.md
Match Single Character with Multiple Possibilities.md
Match Single Characters Not Specified.md
Match Whitespace.md
Match a Literal String with Different Possibilities.md
Positive and Negative Lookahead.md
Remove Whitespace from Start and End.md
Restrict Possible Usernames.md
Reuse Patterns Using Capture Groups.md
Specify Exact Number of Matches.md
Specify Only the Lower Number of Matches.md
Specify Upper and Lower Number of Matches.md
Use Capture Groups to Search and Replace.md
Using the Test Method.md
meta.json
basic-algorithm-scripting.json
basic-data-structures.json
basic-javascript.json
debugging.json
es6.json
functional-programming.json
intermediate-algorithm-scripting.json
javascript-algorithms-and-data-structures-projects.json
object-oriented-programming.json
regular-expressions.json
03-front-end-libraries
04-data-visualization
05-apis-and-microservices
06-information-security-and-quality-assurance
08-coding-interview-prep
09-certificates
docs
formattingConversion
math-challenges
requiresTests
schema
.babelrc
.editorconfig
.eslintignore
.eslintrc
.npmignore
.prettierrc
.travis.yml
CHANGELOG.md
LICENSE.md
README.md
addAssertsToTapTest.js
challengeTitles.js
commitizen.config.js
commitlint.config.js
create-challenge-bundle.js
getChallenges.js
gulpfile.js
index.js
md-conversion.js
mongoIds.js
package-entry.js
package-lock.json
package.json
repack.js
test-challenges.js
unpack.js
unpacked.css
unpacked.js
unpackedChallenge.js
utils.js
docs
news
seed
tools
.editorconfig
.eslintignore
.eslintrc
.gitattributes
.gitignore
.node-inspectorrc
.prettierrc
.snyk
.travis.yml
.vcmrc
CODE_OF_CONDUCT.md
CONTRIBUTING.md
LICENSE.md
README.md
docker-compose-shared.yml
docker-compose.yml
lerna.json
netlify.toml
package-lock.json
package.json
sample.env
67 lines
2.7 KiB
Markdown
67 lines
2.7 KiB
Markdown
![]() |
---
|
||
|
id: 587d7db8367417b2b2512ba1
|
||
|
title: Match All Non-Numbers
|
||
|
challengeType: 1
|
||
|
---
|
||
|
|
||
|
## Description
|
||
|
<section id='description'>
|
||
|
The last challenge showed how to search for digits using the shortcut <code>\d</code> with a lowercase <code>d</code>. You can also search for non-digits using a similar shortcut that uses an uppercase <code>D</code> instead.
|
||
|
The shortcut to look for non-digit characters is <code>\D</code>. This is equal to the character class <code>[^0-9]</code>, which looks for a single character that is not a number between zero and nine.
|
||
|
</section>
|
||
|
|
||
|
## Instructions
|
||
|
<section id='instructions'>
|
||
|
Use the shorthand character class for non-digits <code>\D</code> to count how many non-digits are in movie titles.
|
||
|
</section>
|
||
|
|
||
|
## Tests
|
||
|
<section id='tests'>
|
||
|
|
||
|
```yml
|
||
|
- text: Your regex should use the shortcut character to match non-digit characters
|
||
|
testString: 'assert(/\\D/.test(noNumRegex.source), "Your regex should use the shortcut character to match non-digit characters");'
|
||
|
- text: Your regex should use the global flag.
|
||
|
testString: 'assert(noNumRegex.global, "Your regex should use the global flag.");'
|
||
|
- text: Your regex should find no non-digits in <code>"9"</code>.
|
||
|
testString: 'assert("9".match(noNumRegex) == null, "Your regex should find no non-digits in <code>"9"</code>.");'
|
||
|
- text: Your regex should find 6 non-digits in <code>"Catch 22"</code>.
|
||
|
testString: 'assert("Catch 22".match(noNumRegex).length == 6, "Your regex should find 6 non-digits in <code>"Catch 22"</code>.");'
|
||
|
- text: Your regex should find 11 non-digits in <code>"101 Dalmatians"</code>.
|
||
|
testString: 'assert("101 Dalmatians".match(noNumRegex).length == 11, "Your regex should find 11 non-digits in <code>"101 Dalmatians"</code>.");'
|
||
|
- text: 'Your regex should find 15 non-digits in <code>"One, Two, Three"</code>.'
|
||
|
testString: 'assert("One, Two, Three".match(noNumRegex).length == 15, "Your regex should find 15 non-digits in <code>"One, Two, Three"</code>.");'
|
||
|
- text: Your regex should find 12 non-digits in <code>"21 Jump Street"</code>.
|
||
|
testString: 'assert("21 Jump Street".match(noNumRegex).length == 12, "Your regex should find 12 non-digits in <code>"21 Jump Street"</code>.");'
|
||
|
- text: 'Your regex should find 17 non-digits in <code>"2001: A Space Odyssey"</code>.'
|
||
|
testString: 'assert("2001: A Space Odyssey".match(noNumRegex).length == 17, "Your regex should find 17 non-digits in <code>"2001: A Space Odyssey"</code>.");'
|
||
|
|
||
|
```
|
||
|
|
||
|
</section>
|
||
|
|
||
|
## Challenge Seed
|
||
|
<section id='challengeSeed'>
|
||
|
|
||
|
<div id='js-seed'>
|
||
|
|
||
|
```js
|
||
|
let numString = "Your sandwich will be $5.00";
|
||
|
let noNumRegex = /change/; // Change this line
|
||
|
let result = numString.match(noNumRegex).length;
|
||
|
```
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
</section>
|
||
|
|
||
|
## Solution
|
||
|
<section id='solution'>
|
||
|
|
||
|
```js
|
||
|
// solution required
|
||
|
```
|
||
|
</section>
|