Regular Expressions - Match All Numbers

I know that I have to to put the digit flag and the global flag as I’ve done, but what should I put in the slashes (//). Task: (Use the shorthand character class \d to count how many digits are in movie titles.) Please help me.

EDIT: I see my mistake, I’ve got it now.

let movieName = "2001: A Space Odyssey";
let numRegex = //dg; // Change this line
let result = movieName.match(numRegex).length;

Challenge: Regular Expressions - Match All Numbers

Link to the challenge:

Well between the // goes whatever regular expression you wanna match or test within a string. If the goal is to find numbers it should be / \d /, however this will return the first number found in the string; to make it find every number there is you use the g flag to repeat the process along the whole string.

PS: \d is not a flag, is a metacharacter.

Thanks, have a nice Thanksgiving

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.