Skip to content

Instantly share code, notes, and snippets.

@paulspringett
Last active December 12, 2015 09:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulspringett/4755454 to your computer and use it in GitHub Desktop.
Save paulspringett/4755454 to your computer and use it in GitHub Desktop.
regex = /^(([a-z0-9\-]+\.)+[a-z]{2,})$/
regex.match('example.org')
=> #<MatchData "example.org"...>
regex.match('nota-hostname')
=> nil
regex.match('sub.example.org')
=> #<MatchData "sub.example.org"...>
regex.match('sub.example.a')
=> nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment