Match All Numbers
You've learned shortcuts for common string patterns like alphanumerics. Another common pattern is looking for just digits or numbers.
The shortcut to look for digit characters is \d
, with a lowercase d
. This is equal to the character class [0-9]
, which looks for a single character of any number between zero and nine.
Use the shorthand character class \d
to count how many digits are in movie titles. Written out numbers ("six" instead of 6) do not count.
Tests
- Waiting: 1. Your regex should use the shortcut character to match digit characters
- Waiting: 2. Your regex should use the global flag.
- Waiting: 3. Your regex should find 1 digit in the string
9
. - Waiting: 4. Your regex should find 2 digits in the string
Catch 22
. - Waiting: 5. Your regex should find 3 digits in the string
101 Dalmatians
. - Waiting: 6. Your regex should find no digits in the string
One, Two, Three
. - Waiting: 7. Your regex should find 2 digits in the string
21 Jump Street
. - Waiting: 8. Your regex should find 4 digits in the string
2001: A Space Odyssey
.
/** * Your test output will go here */