1//Adding '/' around regex
2var regex = /\s/g;
3//or using RegExp
4var regex = new RegExp("\s", "g");
1// Tests website Regular Expression against document.location (current page url)
2if (/^https\:\/\/example\.com\/$/.exec(document.location)){
3 console.log("Look mam, I can regex!");
4}