regex.test with global flag is a trap