I am trying to use the following JavaScript RE to match a string where valid characters are uppercase or lowercase letters, numbers, hypens (-) and periods (.). Underscore "_" is not allowed:
pattern = /^([a-zA-z0-9\-\.]+)$/
But when I run the test on the Chrome console: pattern.test ("_ Linux");
The result is correct, but must be false in accordance with our rules. What reason?
source
share