title: Regex for letters, numbers, dashes only?
body: <p>I am trying to validate a second level domain (everything before the .com and after the https://) in Ruby so that I can pass it into my namecheap api requests. Here is what I have so far, but I am not familiar with regex</p>
  
  <pre><code>validates_format_of :sld, with: [a-zA-Z0-9-]
  </code></pre>
  
  <ul>
  <li>no spaces allowed</li>
  <li>no special characters allowed</li>
  <li>however, dashes are allowed</li>
  <li>cannot start with a dash</li>
  <li>cannot end with a dash</li>
  </ul>
  
  <p>I know that uppercase characters do not work in domain names, but I don't want to make users enter their text again. I will downcase the user input and show a flash message on the next page.</p>