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

400 B

title
Match All Non-Numbers

Match All Non-Numbers

Hint 1

  • You should try using a global flag.

Hint 2

  • Try a shorthand character for non-digits characters.

Spoiler Alert!! Solution Ahead!

Solution

let noNumRegex = /\D/g;

Explanation

  • The \D shorthand character is used to match non-digits characters, it has the same result as using [^0-9];