2018-10-04 14:37:37 +01:00
---
id: 587d7db8367417b2b2512ba1
title: Match All Non-Numbers
challengeType: 1
2019-08-05 09:17:33 -07:00
forumTopicId: 301347
2018-10-04 14:37:37 +01:00
---
## 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
tests:
- text: Your regex should use the shortcut character to match non-digit characters
2019-07-24 02:32:04 -07:00
testString: assert(/\\D/.test(noNumRegex.source));
2018-10-04 14:37:37 +01:00
- text: Your regex should use the global flag.
2019-07-24 02:32:04 -07:00
testString: assert(noNumRegex.global);
2018-10-04 14:37:37 +01:00
- text: Your regex should find no non-digits in < code > "9"</ code > .
2019-07-24 02:32:04 -07:00
testString: assert("9".match(noNumRegex) == null);
2018-10-04 14:37:37 +01:00
- text: Your regex should find 6 non-digits in < code > "Catch 22"</ code > .
2019-07-24 02:32:04 -07:00
testString: assert("Catch 22".match(noNumRegex).length == 6);
2018-10-04 14:37:37 +01:00
- text: Your regex should find 11 non-digits in < code > "101 Dalmatians"</ code > .
2019-07-24 02:32:04 -07:00
testString: assert("101 Dalmatians".match(noNumRegex).length == 11);
2018-10-20 21:02:47 +03:00
- text: Your regex should find 15 non-digits in < code > "One, Two, Three"</ code > .
2019-07-24 02:32:04 -07:00
testString: assert("One, Two, Three".match(noNumRegex).length == 15);
2018-10-04 14:37:37 +01:00
- text: Your regex should find 12 non-digits in < code > "21 Jump Street"</ code > .
2019-07-24 02:32:04 -07:00
testString: assert("21 Jump Street".match(noNumRegex).length == 12);
2018-10-04 14:37:37 +01:00
- text: 'Your regex should find 17 non-digits in < code > "2001: A Space Odyssey"</ code > .'
2019-07-27 21:16:04 -07:00
testString: 'assert("2001: A Space Odyssey".match(noNumRegex).length == 17);'
2018-10-04 14:37:37 +01:00
```
< / section >
## Challenge Seed
< section id = 'challengeSeed' >
< div id = 'js-seed' >
```js
2019-06-07 04:23:31 +05:30
let movieName = "2001: A Space Odyssey";
2018-10-04 14:37:37 +01:00
let noNumRegex = /change/; // Change this line
2019-06-07 04:23:31 +05:30
let result = movieName.match(noNumRegex).length;
2018-10-04 14:37:37 +01:00
```
< / div >
< / section >
## Solution
< section id = 'solution' >
```js
2019-06-07 04:23:31 +05:30
let movieName = "2001: A Space Odyssey";
2019-05-03 03:05:26 -07:00
let noNumRegex = /\D/g; // Change this line
2019-06-07 04:23:31 +05:30
let result = movieName.match(noNumRegex).length;
2018-10-04 14:37:37 +01:00
```
2019-07-18 08:24:12 -07:00
2018-10-04 14:37:37 +01:00
< / section >