Been looking for a couple of days now and still could not get my head around it.
This is the phrase,
const phrase = `"That's the password: 'PASSWORD 123'!", cried the Special Agent.\nSo I fled.`;
and this is the expected transformation,
['that's', 'the', 'password', 'password', '123', 'cried', 'the', 'special', 'agent', 'so', 'i', 'fled']
The first element (that's) of the array is the problem area.
I can only get below transformation,
['thats', 'the', 'password', 'password', '123', 'cried', 'the', 'special', 'agent', 'so', 'i', 'fled']
Using below code
const cleanPhrase = phrase.replace(/["':!,.]/g, '').replace(/[\n]/g, ' ').toLocaleLowerCase()
const words = cleanPhrase.split(' ');
Is there a way to ignore the single quotes on 'Password 123' but accept the single quote on that's ?