Match All Letters and Numbers (using shorthand character)

Tell us what’s happening:
i already used shorthand character(\w) in code but it still not accepting and output screen shows

(Your regex should use the shorthand character)

Your code so far

let quoteSample = “The five boxing wizards jump quickly.”;
let alphabetRegexV2 = /[A-Za-z0-9_]/g;

let shortHand = /\w+/;
let result = quoteSample.match(alphabetRegexV2).length;

\w is for Word, not letter.

1 Like

\w doesn’t match a word. It matches a single letter, number, or underscore.

1 Like

i used \W instead of \w and it worked!,thank u for quick respond.

i used \W instead of \w and it worked!

May I ask why in the example of this exercise they used /\w+/ instead of /\w/?

\w matches one single word character, \w+ matches one or more.
Using one or the other depends on what you want your output to be

More than this you will need to post the challenge link, or it is difficult to answer the question

1 Like

Thank you for the help!
This is the link of the challenge: https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/regular-expressions/match-all-letters-and-numbers

I used console.log and I just realized that /\w+/ matches the words that meet the criteria, whereas /\w/ matches the total of characters that meet the criteria :smile::smile: