bradxr
8/4/2018 - 6:44 PM

Match Everything but Letters and Numbers

Search for the opposite (everything but letters and numbers) of \w with \W This shortcut is the same as /[^A-Za-z0-9_]/

let shortHand = /\W/;

let numbers = "42%";
let sentence = "Coding!;

numbers.match(shortHand);   // returns ["%"]
sentence.match(shortHand);    // returns ["!"];