I have a string that looks like this: 20/11/2019
I would like to check if:
- The first number is between 1 and 31
- The second number is between 1 and 12
- The third number is between 2000 and 2999
The numbers are separated by "/".
I have tried using regex, but I'm not familiar with it.
if (ExpDate.matches("[1-31]/[1-12]/[2000-2999]")){
//something happens
}
Is there any way to accomplish this correctly?
Thanks in advance for any help.
Aucun commentaire:
Enregistrer un commentaire