Skip to content

Instantly share code, notes, and snippets.

@gufengxiaoyuehan
Last active December 24, 2017 05:17
Show Gist options
  • Save gufengxiaoyuehan/1a2d30bcbf16194f085bbd3e557bb265 to your computer and use it in GitHub Desktop.
Save gufengxiaoyuehan/1a2d30bcbf16194f085bbd3e557bb265 to your computer and use it in GitHub Desktop.
extract domain from url using regex in scala
val pattern = """(?:https?://)?(?:[^\./]*\.)*([^\./]*\.(?:com|cn|com\.cn|net|org|me))(?::\d+)?(?:$|/.*)""".r
val pattern(url) = "some url"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment