-
-
Save grobie/390646 to your computer and use it in GitHub Desktop.
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
url = %r{ | |
^ | |
([A-Za-z]*) # scheme (e.g. http) | |
: | |
(?: | |
// # mailto: and news: URLs do not require forward slashes | |
)? | |
([0-9.\-A-Za-z@]*) # domain (e.g., www.regexml.org) | |
(?: # port number | |
: | |
(\d{0,5}) | |
)? | |
( # resource (e.g., /sample/resource) | |
/[^?#]* | |
)? | |
(?: # query string | |
\?([^#]*) | |
)? | |
(?: | |
\#(.*) # anchor tag | |
)? | |
$ | |
}x | |
p url.match("scheme://domain.com:8808/sample/resource?query=string#anchor").to_a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment