我需要验证字母字符(在请求中,node.js)和我使用的是:
/[a-zA-Z]+/.test(input)
Run Code Online (Sandbox Code Playgroud)
但是当传递值null时,它被验证OK(regexp返回TRUE)示例:
/[a-zA-Z]+/.test(null) // <--- this returns true :(
Run Code Online (Sandbox Code Playgroud)
有人可以解释一下吗?我需要避免空值,谢谢!