#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?xm)^(?:(?<protocol>[a-z]+):\/\/)?" & @CRLF & _
"(?:(?:(?<username>[^@\r\n:]+))" & @CRLF & _
"(?::(?<password>[^@\r\n]+))?@)?" & @CRLF & _
"(?<host>[^\/:\r\n]+)" & @CRLF & _
"(?::(?<port>\d+))?" & @CRLF & _
"(?:\/(?<path>[^?\r\n]+)?)?" & @CRLF & _
"(?:\?(?<query>[^\r\n]+))?"
Local $sString = "http://server:12345/path/blabla" & @CRLF & _
"http://server.com:1234/path?query_string#fragment_id" & @CRLF & _
"ftp://user:password@server:1234/path" & @CRLF & _
"ftp://user@server:1234/path" & @CRLF & _
"http://www.server.com" & @CRLF & _
"www.server.com/path" & @CRLF & _
"server.com" & @CRLF & _
"http://user@server.com:1234/path?query_string#fragment_id" & @CRLF & _
"user@server.com:1234" & @CRLF & _
""
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