I want to create a regular expression where only numbers are allowed with max length 9 and no minimum length. I came up with \d{9}[0-9] but it isn’t working.
I want to create a regular expression where only numbers are allowed with max
Share
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.
You’re close. Try this:
The ^ and $ match the beginning and the end of the text, respectively.
\d{0,9}matches anywhere in the string, sod0000would pass because it would match the0000even though there is a d in it, which I don’t think you want. That’s why they ^$ should be in there.