I\'m trying to create a regex that will match only when the string has anything but alphas, spaces, and hyphens. In other words, the string can only contain letters, spaces, and
if(someString.match(/[a-z -]+/i){
// it's valid
}
If you are looking for a test for validity:
// from string start to end, only contains '-' "whitespace" or 'a'-'z'
someString.match(/^[-\sa-zA-Z]+$/)
Or the negation:
// has some invalid character not '-' "whitespace" or 'a'-'z'
someString.match(/[^-\sa-zA-Z]/)