Skip to content

Instantly share code, notes, and snippets.

@chvanikoff
Created May 26, 2020 15:16
Show Gist options
  • Save chvanikoff/db019ce4909ec1aa300f59990ff697df to your computer and use it in GitHub Desktop.
Save chvanikoff/db019ce4909ec1aa300f59990ff697df to your computer and use it in GitHub Desktop.
~^
# scheme
[-a-z0-9+.]++://
# username:password (optional)
(?:
[-a-z0-9$_.+!*\'(),;?&=%]++ # username
(?::[-a-z0-9$_.+!*\'(),;?&=%]++)? # password (optional)
@
)?
(?:
# ip address
\d{1,3}+(?:\.\d{1,3}+){3}+
| # or
# hostname (captured)
(
(?!-)[-a-z0-9]{1,63}+(?<!-)
(?:\.(?!-)[-a-z0-9]{1,63}+(?<!-)){0,126}+
)
)
# port (optional)
(?::\d{1,5}+)?
# path (optional)
(?:/.*)?
$~iDx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment