Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No digits Java Regex Pattern

Tags:

java

regex

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 ?

like image 611
Waseem Avatar asked Dec 24 '09 19:12

Waseem


3 Answers

\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*.

like image 69
Tyler Avatar answered Sep 25 '22 20:09

Tyler


\A\D*\Z

a good regex cheatsheet here

like image 25
Arthur Thomas Avatar answered Sep 22 '22 20:09

Arthur Thomas


Try: \D

See the JavaDoc for Pattern

like image 33
Fried Hoeben Avatar answered Sep 26 '22 20:09

Fried Hoeben