--
(more than 1 consecutive -)? e.g. ab--c
-
at the back of words not allow, e.g. abc-
<
^[a-zA-Z0-9](?!.*--)[a-zA-Z0-9-]*[a-zA-Z0-9]$
^[a-zA-Z0-9] /*Starts with a letter or a number*/
(?!.*--) /*Doesn't include 2 dashes in a row*/
[a-zA-Z0-9-]* /*After first character, allow letters or numbers or dashes*/
[a-zA-Z0-9]$ /*Ends with a letter or a number*/
Matches:
Re-play / Re-play-ed
Doesn't Match:
Replay- / Re--Play / -Replay