xxxxxxxxxx
^[a-zA-Z0-9] # start with an alphanumeric character
( # start of (group 1)
[._-](?![._-]) # follow by a dot, hyphen, or underscore, negative lookahead to
# ensures dot, hyphen, and underscore does not appear consecutively
| # or
[a-zA-Z0-9] # an alphanumeric character
) # end of (group 1)
{3,18} # ensures the length of (group 1) between 3 and 18
[a-zA-Z0-9]$ # end with an alphanumeric character
# {3,18} plus the first and last alphanumeric characters,
# total length became {5,20}