更新时间:2023-02-26 14:06:24
如果您正在寻找有效性测试:
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]+$/)
或否定:
// has some invalid character not '-' "whitespace" or 'a'-'z'
someString.match(/[^-\sa-zA-Z]/)