Regex Match Words and More
const phrase = `"That's the password: 'PASSWORD 123'!", cried the Special Agent.\nSo I fled.`;
const words = phrase.toLocaleLowerCase()
.replace(/["!.:,]/g, '')
.split(/\s\'|\'\s|\n|\s/g);
console.log(words);
Recently did this for a stackoverflow question… check it out…
There are other great (better) answers like this one by use MMMahdy-PAPION:
const phrase = `"That's the password: 'PASSWORD 123'!", cried the Special Agent.\nSo I fled.`
console.log(
phrase.toLocaleLowerCase().match(/(?!')[\w']*\w/g)
);