Regular expression help

I am trying to have a field where a user will enter a string like this:

GM - 123 - 12345

So, 2 char then a dash then 3 int then a dash then 5 int

I want the user to just enter GM12312345 and have it automatically format. I assume I can use a regular expression so I tried this and it didn't work:

constraint="regex(.,\A[a-zA-Z]{2}-\d{3}-\d{5}\z"/>

Any ideas?

Thanks in advance!

Sorry, I solved my own problem. Here is the solution

constraint="regex(., '^[a-zA-Z]{2}-[0-9]{3}-[0-9]{5}$')"/>