Created
June 22, 2021 13:08
-
-
Save T99/dd1002362f002e453dbdb74bd36d1a57 to your computer and use it in GitHub Desktop.
(Mostly) RFC3986 Compliant URL/URI Parsing Regex
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
/(?(DEFINE) | |
(?<defunreserved>[A-Za-z0-9-._~]) | |
(?<defpctencoded>\%[0-9A-Fa-f]{2}) | |
(?<defsubdelims>[!$&'()*+,;=]) | |
(?<defpchar>((?P>defunreserved)|(?P>defpctencoded)|(?P>defsubdelims)|:|@)) | |
(?<defscheme>[A-Za-z][A-Za-z0-9+-.]*) | |
(?<defhierpart>.*?) | |
(?<defquery>((?P>defpchar)|\/|\?)*) | |
(?<deffragment>((?P>defpchar)|\/|\?)*) | |
) | |
^(?'scheme'(?P>defscheme)):\/\/(?'host'(?P>defhierpart))(?'query'\?(?P>defquery))*(?'fragment'\#(?P>deffragment))*$ | |
/gmx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Find RFC3986 here.