开发者

Regex to enter only alphabets and donot enter any other characters

I have a Regex which contains the following .Is this suitable restricting the user only to enter alphabets and do not allow numbers ,special characters开发者_高级运维 such as (',@#$%^&*())

^[a-zA-Z]+$


Yes, but it also does not allow accented characters and other non-ASCII letters (ä, à, ñ, ß and many others).

^\p{L}+$ is an alternative for this scenario, if your regex engine is Unicode-aware.


^[a-zA-Z]+$

Yes, it only allows a..z and A..Z. This means a space is also not allowed. At least one character, so an empty string is not matched either.


That regex will only match alphanumeric characters from a to z, upper- and lowercase. So I guess that is what you wanted. By the way: because of the plus sign, at least one of the characters from your character class is required.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜