freeCodeCamp/guide/english/certifications/javascript-algorithms-and-d.../regular-expressions/match-all-numbers/index.md

389 B

title
Match All Numbers

Match All Numbers

Hint 1

  • A global flag will help you get through this challenge.

Hint 2

  • Try using a shorthand character for digits.

Spoiler Alert!! Solution Ahead!

Solution

let numRegex = /\d/g;

Explanation

  • The \d shorthand character is a shortcut for [0-9], it search for any number between 0 and 9.