I would like to test if user type only alphanumeric value or one \"-\".
hello-world -> Match hello-first-world -> match this-
(^-)|-{2,}|[^a-zA-Z-]|(-$) looks for invalid characters, so zero matches to that pattern would satisfy your requirement.
(^-)|-{2,}|[^a-zA-Z-]|(-$)