>You are misinterpreting the {1,20} and {1,12}. These mean that the group preceding it is repeated between 1 and 20 or 1 and 12 times respectively. The expression you probably want is: ([A-Za-z0-9][A-Za-z0-9\-]{19})\-([A-Za-z0-9]{12})
>
>To break this expression down:
>The first [A-Za-z0-9] indicates the first character must be A-Z, a-z, or 0-9.
>The following [A-Za-z0-9\-]{19} indicates the next 19 characters must be A-Z, a-z, 0-9, or -.
>The parenthesis around these two make it into a capturing group.
>The next \- matches a literal hyphen.
>The final ([A-Za-z0-9]{12}) matches 12 characters of A-Z, a-z, or 0-9.
>
>If any of the blocks can be variable length, change the {n} to {n,m} where n is the least number of times that block can repeat, and m is the most it can repeat.
http://www.regular-expressions.info/refrepeat.html also provides more information on the variations of the repeating indicator.
Thanks, this is very valuable.
Basically, this is more readable I would assume for someone who tries to interpret this for the first time:
([A-Za-z0-9]{1}[A-Za-z0-9\-]{19})\-([A-Za-z0-9]{12})
So, at least, in the first part, we know it is only for character 1. Then, we have another filter for the next 19 characters.
Or:
([A-Za-z0-9]{1}[A-Za-z0-9\-]{19})-([A-Za-z0-9]{12})
...if we ignore the \ which is only there to make sure the - is interpreted ok.