I think because “w” is a capital letter it should just return “C”. But it does not!??
let shortHand = /\W/;
let numbers = "42%";
let sentence = "Coding!";
numbers.match(shortHand); // Returns ["%"]
sentence.match(shortHand); // Returns ["!"]
I think because “w” is a capital letter it should just return “C”. But it does not!??
let shortHand = /\W/;
let numbers = "42%";
let sentence = "Coding!";
numbers.match(shortHand); // Returns ["%"]
sentence.match(shortHand); // Returns ["!"]
Hey @anon58011934,
Capital W i.e. /\W/ matches any character that is not a word character. Here, word includes alphanumeric characters.
If you had small w i.e. /\w/ matches any word character that means opposite of the above case.
Also, whenever i have to do and understand regex, i head over to https://regexr.com/
It’s pretty helpful in understanding regex.
Hope this helps.
Thank you so much 