How to enter Regex code

Horalia Rodriguez
Horalia Rodriguez used Ask the Experts™
on
What is the code in regex to ensure user enters a minimum of 6 digits and a maximum of 6 digits? I currently have

\d{6,6}

But I don't get the error message indicating that I have entered more than 6 digits.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Dr. KlahnPrincipal Software Engineer

Commented:
Do you require leading zero suppression, i.e., is 000005 as valid a number as 472625?
IT Guru
Most Valuable Expert 2011
Commented:
You'll be wanting:
^\d{6}$

Open in new window


The ^ and $ match the start and end of the string, respectively. Without those, the pattern will match if there are 6 digits anywhere in a longer string.
Horalia RodriguezIT Developer

Author

Commented:
No, just 6 digits, 0 - 9, leading zeros included. Thanks.
Terry WoodsIT Guru
Most Valuable Expert 2011

Commented:
Did you see my solution?
Horalia RodriguezIT Developer

Author

Commented:
Thanks Terry! Was on vacation for a few weeks, hadn't logged in to close.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial