Regular expression to accept only characters (a-z) in a textbox

后端 未结 8 1433
北荒
北荒 2021-01-05 12:16

What is a regular expression that accepts only characters ranging from a to z?

8条回答
  •  暖寄归人
    2021-01-05 13:10

    Try this to allow both lower and uppercase letters in A-Z:

    /^[a-zA-Z]+$/
    

    Remember that not all countries use only the letters A-Z in their alphabet. Whether that is an issue or not for you depends on your needs. You may also want to consider if you wish to allow whitespace (\s).

提交回复
热议问题