I am trying to match a string containing 1 to 3 digits,
example:
1
2
123
3
This is what i tried,
[\s]?[0-9]{1,3}[\s]?
This is matching,
123 ->a space after 123
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your question is unclear, but it seems you’re looking for a string that
In that case, the regex is
^(?=.*\d)[\d\s]{3}$. As a Java string:"^(?=.*\\d)[\\d\\s]{3}$".Explanation: