Regex Validation in Java to validate a String having numbers of length 5

Hello,
I need a regex expression to validate a string that should have only numbers and of length 5.
Please help..
panshul007Asked:
Who is Participating?
 
silemoneConnect With a Mentor Commented:
/\d{5}/  for 5 digits   11111 will match but 1, 11, 111, 1111,  will not nor anything > 5

[0-9]{5] for five digits  save as the above

remember

[0-9]{0,5}  <-- this can be nothing, 1, 11, 111, 1111, 11111, but not > than 5

0
 
silemoneCommented:
[0-9]{0,5} for up to 5 characters but can be less

[0-9][0-9][0-9][0-9][0-9]  simple 5 characters
0
 
panshul007Author Commented:
Thanks for the help..
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.