简体   繁体   中英

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 patient , 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 : [ab,AZ, ,-]+

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM