I would like to validate a hostname using only regualr expression.
Host Names (or \'labels\' in DNS jargon) were traditionally defined by RFC 952 and RFC 1123 and m
Ruby regular expressions are multiline by default, and so something like Rails warns against using ^ and $. This is Mark's answer with safe start- and end of string characters:
^
$
\A(?![0-9]+$)(?!-)[a-zA-Z0-9-]{,63}(?