0

I would like to check if a variable has only alphabets (a-z) and another variable will contains only digits. So, I used matches("[0-9]+") to check only digits and matches("[a-zA-Z]+( +[a-zA-Z]+)*") to check only alphabets which can be lower or upper case. However, those regex are not working for digit and alphabets mixture. Like aa2 and 2aa. What I am doing wrong? What will be the correct way to check strictly alphabets and digits?

Frank Underwood
  • 111
  • 1
  • 2
  • 6

0 Answers0