Jin Kwon Jin Kwon - 3 months ago 8
Java Question

How can I match an input of not entirely digits?

What is the proper expression for checking that any input contains at least one non-digit char?

"11111111" doesn't match!
"1111111a" match!
"1111 111" match!

Answer

You can use the following regex where \D used for match any non-digit([^0-9]) character.

.*\D.*

Regex explanation here

Regular expression visualization