Regular expression for only characters a-z, A-Z

后端 未结 4 1994
萌比男神i
萌比男神i 2020-12-02 22:57

I don\'t know how to create a regular expression in JavaScript or jQuery.

I want to create a regular expression that will check if a string contains only characters

4条回答
  •  长情又很酷
    2020-12-02 23:28

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

    Off the top of my head.

    Edit:

    Or if you don't like the weird looking literal syntax you can do it like this

    new RegExp("^[a-zA-Z]+$");
    

提交回复
热议问题