\d
with a lowercase d
. You can also search for non-digits using a similar shortcut that uses an uppercase D
instead.
The shortcut to look for non-digit characters is \D
. This is equal to the character class [^0-9]
, which looks for a single character that is not a number between zero and nine.
\D
to count how many non-digits are in movie titles.
"9"
.
testString: assert("9".match(noNumRegex) == null);
- text: Your regex should find 6 non-digits in "Catch 22"
.
testString: assert("Catch 22".match(noNumRegex).length == 6);
- text: Your regex should find 11 non-digits in "101 Dalmatians"
.
testString: assert("101 Dalmatians".match(noNumRegex).length == 11);
- text: Your regex should find 15 non-digits in "One, Two, Three"
.
testString: assert("One, Two, Three".match(noNumRegex).length == 15);
- text: Your regex should find 12 non-digits in "21 Jump Street"
.
testString: assert("21 Jump Street".match(noNumRegex).length == 12);
- text: 'Your regex should find 17 non-digits in "2001: A Space Odyssey"
.'
testString: 'assert("2001: A Space Odyssey".match(noNumRegex).length == 17);'
```