>There is something I am trying to understand with a RegEx expression.
>
>Here is an expression: ([A-Za-z0-9-]{1,20})-([A-Za-z0-9]{1,12})
>
>That one allows alphanumeric characters from anywhere from the 1st to the 20th character. This includes as well a dash starting from position 2.
>
>This is the part I cannot understand. What in there is a representation that the dash is valid from position 2?
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.