Match All Letters and Numbers

Tell us what’s happening:

Your code so far


let quoteSample = "The five boxing wizards jump quickly.";
let alphabetRegexV2 = /\w+/gi; // Change this line
let result = quoteSample.match(alphabetRegexV2).length;

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/match-all-letters-and-numbers

1 Like

Close but you are not matching individual characters but whole words.

If you have time take your regex for a test drive on https://regexr.com/

2 Likes

Your regex will match all “clusters” of alphanumeric characters. For example, in the first test case

Your regex should find 31 alphanumeric characters in "The five boxing wizards jump quickly."

Your regex will not match individual characters, but rather count the alphanumeric clusters: The, five, boxing, wizards, jump, quickly.

See this link: regex101: build, test, and debug regex
Play around with removing and retyping the + symbol and compare the results.

5 Likes

just came across this challenge. thank you guys for the explanation!

Yes, me too =)) :grinning: :grinning: :grinning: