Regular expression for field in the format of NNNN-NNN-NNNN

I have an web form with an input field where people will enter the data in the format

Where N represents a number. And each set of numbers is seperated by a hyphen. Also two consecutive hyphens are not allowed. Also I need to prevent the applicaiton user from starting the number sequence with a hyphen or ending with a hyphen. So this is not allowed:

Basically the rule is a first set of numbers followed by a hyphen, followed by another set of numbers, a hyphen and followed by third set of numbers. The total number of digits entered cannot exceed 20.

Can someone help me figure this out?  I initially created this regular expression which I used to allow people to enter up to 20 numbers. The requirements have changed now so that I have to use hypens for input according to what I described earlier. This is what I initially had:

This is a difficult problem I have not been able to figure out. I will offer 400 points for some expert help.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

"I have an web form with an input field where  people will enter the data in the format

Hi! You may try this one. Hope it helps.

(D-)?\d{5}(-| )\d{3}(-| )\d{5}

Open in new window

Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

Sorry, didn't see TOTAL digits count should be less than 20.
1) ^\d+-\d+-\d+$
2) And set MaxLength for TextBox equal to 18
That's it
Oops misprint, MaxLength should be 22 (20 digits + 2 hypens)
^(?=.{1,22}$)\d+-\d+-\d+$ then--I didn't notice I needed to account for the hyphens.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.