Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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