#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)^(?>(?'protocol'[a-zA-Z]+)://)?(?'domain'[a-zA-Z0-9.\-_]*)?(?>:(?'port'\d{1,5}))?/(?'path'[a-zA-Z0-9_\-%]+)(?:(?>\?(?'query'[a-zA-Z0-9_\-=&%]+))()|(?>#(?'anchor'[a-zA-Z0-9_\-%]+))()){0,2}$"
Local $sString = "https://localhost:5000/test?id=10&class=5#header" & @CRLF & _
"http://example.com:443/test#header" & @CRLF & _
"ws://example.com/test?id=10&class=5" & @CRLF & _
"/test?id=10&class=5" & @CRLF & _
"/test?t=10" & @CRLF & _
"/test#10" & @CRLF & _
"/test%20test" & @CRLF & _
"/test#10?data=test"
Local $sSubst = "protocol: ${protocol}\nhost name: ${domain}\nport: ${port}\npath: /${path}\nquery: ${query}\nanchor: ${anchor}\n"
Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst)
MsgBox($MB_SYSTEMMODAL, "Result", $sResult)
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm