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?
Asked
Active
Viewed 28 times
0

Frank Underwood
- 111
- 1
- 2
- 6
-
Use `find()`... – Wiktor Stribiżew Nov 17 '16 at 10:19
-
can you provide the acceptable and some non acceptable inputs for you? – mayank agrawal Nov 17 '16 at 10:28