This seems to match the rules I have defined, but I only starting learning regex tonight, so I am wondering if it is correct.
Rules:
You regular expression can be simplified to:
/^[a-zA-Z0-9]+([_ -]?[a-zA-Z0-9])*$/
Visualized with Regexper:
As you can see a user name always has to start with an alphanumeric character. Special characters (_, , -) have to be followed by an alphanumeric character. The last character has to be an alphanumeric character.