#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)^((?:https?|ftp|smtp):\/\/)?((?:[a-z0-9]+\.)*[a-z]+|(?:(?:25[0-5]|2[0-4]\d|1?\d{2}|\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d{2}|\d))(:\d+)?(\/.+\/?)*$"
Local $sString = "https://www.reddit.co.jp/r/ProgrammerHumor/comments/vxhbku/a_regex_god/" & @CRLF & _
"https://www.reddit.com/r/ProgrammerHumor/comments/vxhbku/a_regex_god/" & @CRLF & _
"https://old.reddit.com/r/ProgrammerHumor/comments/vxhbku/a_regex_god/" & @CRLF & _
"https://reddit.co.jp/r/ProgrammerHumor/comments/vxhbku/a_regex_god/" & @CRLF & _
"https://reddit.com/r/ProgrammerHumor/comments/vxhbku/a_regex_god/" & @CRLF & _
"https://localhost/r/ProgrammerHumor/comments/vxhbku/a_regex_god/" & @CRLF & _
"https://127.0.0.1/r/ProgrammerHumor/comments/vxhbku/a_regex_god/" & @CRLF & _
"https://127.0.0.1:3000/r/ProgrammerHumor/comments/vxhbku/a_regex_god/" & @CRLF & _
"https://localhost:3000/r/ProgrammerHumor/comments/vxhbku/a_regex_god/" & @CRLF & _
"https://reddit.com:3000/r/ProgrammerHumor/comments/vxhbku/a_regex_god/" & @CRLF & _
"https://new.reddit.com:3000/r/ProgrammerHumor/comments/vxhbku/a_regex_god/" & @CRLF & _
"https://420.reddit.com:3000/r/ProgrammerHumor/comments/vxhbku/a_regex_god/" & @CRLF & _
"ftp://ftp.mitsu.xd:6969/secret-linux-isos" & @CRLF & _
"smtp://69.420.com/does-smtp-even-supports-paths?idk=pls%20help" & @CRLF & _
"https://pbs.twimg.com/media/FXiW8wAXwAAqKe3.jpg?name=orig" & @CRLF & _
"" & @CRLF & _
"# Don't match these:" & @CRLF & _
"https://foo#bad.com/r/ProgrammerHumor/comments/vxhbku/a_regex_god/" & @CRLF & _
"https://.../r/ProgrammerHumor/comments/vxhbku/a_regex_god/" & @CRLF & _
"https://1024.0.0.7/r/ProgrammerHumor/comments/vxhbku/a_regex_god/" & @CRLF & _
"https://360.0.0.7/r/ProgrammerHumor/comments/vxhbku/a_regex_god/" & @CRLF & _
"https://127.w.0.1/r/ProgrammerHumor/comments/vxhbku/a_regex_god/" & @CRLF & _
"" & @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