Test if string contains only letters (a-z + é ü ö ê å ø etc..)

后端 未结 12 1335
不思量自难忘°
不思量自难忘° 2020-12-04 18:12

I want to match a string to make sure it contains only letters.

I\'ve got this and it works just fine:

var onlyLetters = /^[a-zA-Z]*$/.test(myString)         


        
12条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-04 18:40

    There are some shortcuts to achive this in other regular expression dialects - see this page. But I don't believe there are any standardised ones in JavaScript - certainly not that would be supported by all browsers.

提交回复
热议问题