开发者

No digits Java Regex Pattern

开发者 https://www.devze.com 2022-12-14 16:27 出处:网络
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

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

精彩评论

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