Here is a snippet of the problem I am running into
console.log(/^true|false|(([- /*^]?\d (\.\d )?)*)$/.test('foo'))
console.log(/^true|false$/.test('foo'))
console.log(/^([- /*^]?\d (\.\d )?)*$/.test('foo'))
This works fine in other regexp testers, but js consistently fails this test. Can anyone explain what I'm doing wrong here. Thank you
CodePudding user response:
^a|b|c$
means ^a
or b
or c$
So first expression should be
console.log(/^(true|false|(([- \/*^]?\d (\.\d )?)*))$/.test('foo'))