Created
October 31, 2018 08:51
-
-
Save sbatururimi/1ab1b3ee119f6f24d54f3a253c632797 to your computer and use it in GitHub Desktop.
Parsing urls to obtain for example the host
This file contains hidden or 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
regex = r"^[a-z][a-z0-9+\-.]*:\/\/([a-z0-9\-._~%!$&'()*+,;=]+@)?([a-z0-9\-._~%]+|\[[a-z0-9\-._~%!$&'()*+,;=:]+\])" | |
\A | |
[a-z][a-z0-9+\-.]*:// # Scheme | |
([a-z0-9\-._~%!$&'()*+,;=]+@)? # User | |
([a-z0-9\-._~%]+ # Named or IPv4 host | |
|\[[a-z0-9\-._~%!$&'()*+,;=:]+\]) # IPv6+ host | |
Source | |
https://www.oreilly.com/library/view/regular-expressions-cookbook/9781449327453/ch08s10.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment