I would like to test if user type only alphanumeric value or one \"-\".
hello-world -> Match
hello-first-world -> match
this-
I'm not entirely sure if this works because I haven't done regex in awhile, but it sounds like you need the following:
/^[A-Za-z0-9]+(-[A-Za-z0-9]+)+$/
You're requirement is split up in the following:
I'm just not sure if I did the regex properly to follow that format.