#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?mxi)(?#First, match the protocol)" & @CRLF & _
"(?:https?|ftp)://" & @CRLF & _
"(?#Next, check for optional username and/or password)" & @CRLF & _
"(?#Note: The following two char classes are functionally equivalent)" & @CRLF & _
"(?:[\x21-\x39\x3b-\x3f\x41-\x7e]+(?::[!-9;-?A-~]+)?@)?" & @CRLF & _
"(?#Next, let's match the domain [with support for Punycode ])" & @CRLF & _
"(?:xn--[0-9a-z]+|[0-9A-Za-z_-]+\.)*(?:xn--[0-9a-z]+|[0-9A-Za-z-]+)\.(?:xn--[0-9a-z]+|[0-9A-Za-z]{2,10})" & @CRLF & _
"(?#Let's match on optional port)" & @CRLF & _
"(?::(?:6553[0-5]|655[0-2]\d|65[0-4]\d{2}|6[0-4]\d{3}|[1-5]\d{4}|[1-9]\d{1,3}|\d))?" & @CRLF & _
"(?#Next, let's match on the path)" & @CRLF & _
"(?:/[\x21\x22\x24\x25\x27-x2e\x30-\x3b\x3e\x40-\x5b\x5d-\x7e]*)*" & @CRLF & _
"(?#Next, let's match on an anchor)" & @CRLF & _
"(?:\#[\x21\x22\x24\x25\x27-x2e\x30-\x3b\x3e\x40-\x5b\x5d-\x7e]*)?" & @CRLF & _
"(?#Last, but not least, we match on URI params)" & @CRLF & _
"(?:\?[\x21\x22\x24\x25\x27-\x2e\x30-\x3b\x40-\x5b\x5d-\x7e]+=[\x21\x22\x24\x25\x27-\x2e\x30-\x3b\x40-\x5b\x5d-\x7e]*)?" & @CRLF & _
"(?#Additional params)" & @CRLF & _
"(?:&[\x21\x22\x24\x25\x27-\x2e\x30-\x3b\x40-\x5b\x5d-\x7e]+=[\x21\x22\x24\x25\x27-\x2e\x30-\x3b\x40-\x5b\x5d-\x7e]*)*" & @CRLF & _
""
Local $sString = "https://thechildrenareourfuture.org/#SomeRandomAnchorGoesHere" & @CRLF & _
"http://user:pass@example.com:8080/omega:33" & @CRLF & _
"https://www.google.com:65535/" & @CRLF & _
"https://www.google.com:42069/" & @CRLF & _
"https://www.google.com:9876/" & @CRLF & _
"https://www.google.com:59999/" & @CRLF & _
"https://www.google.com:10000/" & @CRLF & _
"https://www.google.com:1234/" & @CRLF & _
"https://www.google.com:53/" & @CRLF & _
"https://www.google.com:123/" & @CRLF & _
"https://www.google.com:0/" & @CRLF & _
"ftp://username:password@example.com:21/path/here/to/file.tar.gz" & @CRLF & _
"http://google.com?redirect=https%3A%2F%2Flocalhost%3A8080&var2=somethingelse" & @CRLF & _
"https://john.smith@github.com/UserGroup/repo.git" & @CRLF & _
"https://mattermost.com:8065/team/messages/@john.smith" & @CRLF & _
"https://punycode.xn--j6w193g" & @CRLF & _
"" & @CRLF & _
"smtp://somesite.com/myFile.php" & @CRLF & _
"SMTP://SOMESITE.COM/MYFILE.PHP" & @CRLF & _
"unknown://somesite.com/fiLeNuM12345.php" & @CRLF & _
"//SomeSite.ru/foO.php" & @CRLF & _
"://SomeOtherSite.oRg/baRR.php" & @CRLF & _
"" & @CRLF & _
"https://_sub1.sub2.sub3.s-u_b4.domain.com" & @CRLF & _
"" & @CRLF & _
"http://username:password@subdomain.domain.co.uk/path/to/file.html#Anchor1?key1=value1&key2=value2"
Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH)
Local $aFullArray[0]
For $i = 0 To UBound($aArray) -1
_ArrayConcatenate($aFullArray, $aArray[$i])
Next
$aArray = $aFullArray
; Present the entire match result
_ArrayDisplay($aArray, "Result")
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