I am trying to use following JavaScript RE to match the string where allowed characters are uppercase or lowercase letters, digits, hypens (-), and periods (.). The underscore "_" is not allowed:
pattern = /^([a-zA-z0-9\-\.]+)$/
But when I run the test in the Chrome console: pattern.test("_linux");
The result is true, but should be false according to our rules. What's the reason?
A-zshould beA-Z..doesn't have to be escaped inside the character class.here-