Last active
December 24, 2017 05:17
-
-
Save gufengxiaoyuehan/1a2d30bcbf16194f085bbd3e557bb265 to your computer and use it in GitHub Desktop.
extract domain from url using regex in scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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