-9

I want to validate the input data to allow only alphanumeric value. It should not be only numbers or only alphabets. How to do that using regex expression in Java?

dda
  • 6,030
  • 2
  • 25
  • 34
  • You can find another resolve ways here [How to create a regex for accepting only alphanumeric characters?](http://stackoverflow.com/questions/5988228/how-to-create-a-regex-for-accepting-only-alphanumeric-characters) – Duy Huynh Dec 21 '15 at 10:23

1 Answers1

2

You can very easily find the character class for alphanumeric characters in the Pattern javadoc:

\p{Alnum} An alphanumeric character: [\p{Alpha}\p{Digit}]

Andy Turner
  • 137,514
  • 11
  • 162
  • 243