-- (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]+)*$
Using this regular expression, the hyphen is only matched just inside the group. This hyphen has the [A-Za-z0-9]+ sub-expression appearing on each side. Because this sub-expression matches on one or more alpha numeric characters, its not possible for a hyphen to match at the start, end or next to another hyphen.