开发者

No digits Java Regex Pattern

I want a regex pattern to check that the string doesn't contain any digits .

For Illustration : I'm coding a Hospital System and I want from user to enter the name of the patie开发者_如何学JAVAnt , Of course the name shouldn't contain any digits , how can I do this by Regex ?


\D is a non-digit, and so then \D* is any number of non-digits in a row. So your whole string should match \D*.


\A\D*\Z

a good regex cheatsheet here


Try: \D

See the JavaDoc for Pattern


Well names usually alphabetical, so this will be good : [a-b,A-Z, ,-]+

EDIT : [a-zA-Z- ',]+

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜