Can only be composed of "0-9a-za-z" and "-", and "-" can not appear at the tail, at least one bit in length.
Ask for the opinion of the general cow kinky.
Reply content:
Can only be composed of "0-9a-za-z" and "-", and "-" can not appear at the tail, at least one bit in length.
Ask for the opinion of the general cow kinky.
^[0-9a-za-z][0-9a-za-z\-]*[0-9a-za-z]$
Above the wrong, modify one:
^(?! -) [a-z0-9a-z-]*[a-z0-9a-z]$
Do not start with--and end with an alphanumeric length, which can be 1 or more.
/^(?! \-) [0-9a-za-z\-]*? [0-9a-za-z] {1}$/
^ ([0-9a-za-z]{1}[0-9a-za-z-]*? [0-9a-za-z] {1}| [0-9a-za-z] {1}) $/^[0-9a-za-z]+ ([0-9a-za-z-]+[^-\w_]) *$/
The key is a word, so give him a group on the question who asked on the Zhihu.
Yes, the domain name is this format, not including the suffix.
In fact, separation is very simple thing, there is no need for a very complex and inefficient regular
!/^-/.test (String) &&!/-$/.test (String) &&/^[0-9a-za-z\-]+$/.test (String)
function test ($s, $t) { var_dump (Preg_match (' #^ (?! -) [0-9a-za-z-]+ (?