I have a form input which is where I only need to take speakable text phrase ( i.e no numbers, symbols etc )
I’m using following Regex pattern to test the user inputs.
const friendlyPhraseReg = new RegExp(/^[aA-zZs]+$/);
friendlyPhraseReg.test('@@') // false
friendlyPhraseReg.test('11') // false
friendlyPhraseReg.test('%%') // false
friendlyPhraseReg.test('&&') // false
friendlyPhraseReg.test(')') //false
friendlyPhraseReg.test('"') //false
friendlyPhraseReg.test('/') //false
It all make sense until I try to test following two strings
friendlyPhraseReg.test('\') // true
friendlyPhraseReg.test('^^') // true
Why does it only return true for ‘^’ and ” ? I’m not very good with regex so pardon me if im asking a stupid question. Can someone clear me why its return true only for those two symbols ?