Skip to content

Instantly share code, notes, and snippets.

@webgtx
Created May 26, 2023 00:25
Show Gist options
  • Select an option

  • Save webgtx/d47fa5b78ba82055684c92cce0c7d38a to your computer and use it in GitHub Desktop.

Select an option

Save webgtx/d47fa5b78ba82055684c92cce0c7d38a to your computer and use it in GitHub Desktop.
Regex in ruby, good example
def domain_name(url)
regex = /(http|https):\/\/(?:www\.)?(?<domain_name>.*?)\./
url.match(regex)[:domain_name]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment