title: What is a regular expression which will match a valid domain name without a subdomain?
body: <p>I need to validate a domain name:</p>
  
  <p><strong>google.com</strong></p>
  
  <p><strong>stackoverflow.com</strong></p>
  
  <p>So a domain in its rawest form - not even a subdomain like www.</p>
  
  <ol>
  <li>Characters should only be <strong>a-z</strong> | <strong>A-Z</strong> | <strong>0-9</strong> and <strong>period</strong>(.) and <strong>dash</strong>(-)</li>
  <li>The domain name part should not start or end with dash (-) <em>(e.g. -google-.com)</em></li>
  <li>The domain name part should be between 1 and 63 characters long</li>
  <li><strike>The extension (TLD) can be anything under #1 rules for now, I may validate them against a list later, it should be 1 or more characters though</strike></li>
  </ol>
  
  <p><strike>Edit: TLD is apparently 2-6 chars as it stands</strike></p>
  
  <p><strong>no. 4 revised:</strong> TLD should actually be labelled "subdomain" as it should include things like .co.uk -- I would imagine the only validation possible (apart from checking against a list) would be 'after the first dot there should be one or more characters under rules #1</p>
  
  <p>Thanks very much, believe me I did try!</p>