#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?im)\b(^(http|https|wss|ws|ftp|ftps):\/\/127[.](?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)[.](?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)[.](?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)|^(http|https|wss|ws|ftp|ftps):\/\/(10)([.](25[0-5]|2[0-4][0-9]|1[0-9]{1,2}|[0-9]{1,2})){3}|^(http|https|wss|ws|ftp|ftps):\/\/localhost|^(http|https|wss|ws|ftp|ftps):\/\/172[.](0?16|0?17|0?18|0?19|0?20|0?21|0?22|0?23|0?24|0?25|0?26|0?27|0?28|0?29|0?30|0?31)[.](?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)[.](?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)|^(http|https|wss|ws|ftp|ftps):\/\/192[.]168[.](?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)[.](?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)|^(http|https|wss|ws|ftp|ftps):\/\/169[.]254[.](?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)[.](?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)|^(http|https|wss|ws|ftp|ftps):\/\/::1|^(http|https|wss|ws|ftp|ftps):\/\/[fF][cCdD][0-9a-fA-F]{2}(?:[:][0-9a-fA-F]{0,4}){0,7}|^(http|https|wss|ws|ftp|ftps):\/\/[fF][eE][89aAbB][0-9a-fA-F](?:[:][0-9a-fA-F]{0,4}){0,7})(?:\/([789]|1?[0-9]{2}))?\b"
Local $sString = "# loopback" & @CRLF & _
"http://127.0.0.0:80" & @CRLF & _
"https://127.0.0.0000 # only three digits supported here" & @CRLF & _
"" & @CRLF & _
"# Localhost" & @CRLF & _
"http://localhost:25" & @CRLF & _
"https://localhost:8080" & @CRLF & _
"HTTP://LoCALhosT:99 # Case insensitive" & @CRLF & _
"ws://localhost:7777" & @CRLF & _
"wss://localhost:9200" & @CRLF & _
"https://google.com/blah/localhost/ # This should not alert" & @CRLF & _
"" & @CRLF & _
"# Web Sockets" & @CRLF & _
"ws://localhost:2121/sockjs-node" & @CRLF & _
"wss://localhost:5882/" & @CRLF & _
"" & @CRLF & _
"# FTP" & @CRLF & _
"ftp://192.168.0.1" & @CRLF & _
"ftps://127.0.0.1" & @CRLF & _
"ftps://localhost" & @CRLF & _
"" & @CRLF & _
"# A" & @CRLF & _
"wss://10.0.0.1/10" & @CRLF & _
"ws://10.255.22.33" & @CRLF & _
"" & @CRLF & _
"# B" & @CRLF & _
"http://172.17.100.155/32 # 172.16.0.0 to 172.31.255.255" & @CRLF & _
"http://172.15.1.1 # This should not fire" & @CRLF & _
"http://172.32.1.1 # This should not fire" & @CRLF & _
"" & @CRLF & _
"# C" & @CRLF & _
"https://192.168.1.1/random/path" & @CRLF & _
"wss://192.168.1.255" & @CRLF & _
"" & @CRLF & _
"# IPv6" & @CRLF & _
"http://fc00:833e:d648:f196:5c6c:1d9a:a14b:0d59 # Private IPv6" & @CRLF & _
"http://fc01:67e5::6a66:34a7" & @CRLF & _
"http://FC02:5fcf:e093:bb10:ce77:b5c9::/112" & @CRLF & _
"http://fc03:49bd:b7c1:5685:fa0a:87e9::2/128" & @CRLF & _
"http://fc04:::2 hmpf" & @CRLF & _
"http://0de9:b022:883f:2c3c:7dba:a184:7576:4531 # public IP addresses" & @CRLF & _
"http://04e4:e53b:0c2f:2990:27ad:0464:6dd3:b6b3" & @CRLF & _
"http://0319:3b4a:546e:d480:4814:f885:3396:bba2" & @CRLF & _
"http://5394:03f5:606f:273e:e343:d94a:610a:3f2e" & @CRLF & _
"http://63cd:ad1f:7ffb:62c7:cc17:6e20:9b59:2f7d" & @CRLF & _
"" & @CRLF & _
"False Positives Check # Should not match any" & @CRLF & _
"https://c091ab33-ae6f-425e-9b41-a50d59eef025.organizations.api.brightspace.com/888654/image?version=c44605a0-fc75-4c49-85b6-e43cb5f42978" & @CRLF & _
"/course-images/images/a02b640d-fd9e-428e-8e77-5ac9c61d21b2" & @CRLF & _
"https://10207287.fls.doubleclick.net/activityi;src=10207287;type=counter;cat=uship0;ord=4880235517192;gtm=2wg3h0;auiddc=2059049732.1617109349;u1=https%3A%2F%2Fwww.uship.com%2Fregister%2F;u2=undefined;u3=undefined;u4=undefined;~oref=https%3A%2F%2Fwww.uship.com%2Fregister%2F" & @CRLF & _
"" & @CRLF & _
"# More "crap"" & @CRLF & _
"wss://30.168.1.255.1" & @CRLF & _
"wss://127.1" & @CRLF & _
"https://192.168.1.256" & @CRLF & _
"wss://-1.2.3.4" & @CRLF & _
"wss://1.1.1.1." & @CRLF & _
"wss://3...3" & @CRLF & _
"wss://255.255.255.255" & @CRLF & _
"wss://0.0.0.0" & @CRLF & _
"wss://1.1.1.01" & @CRLF & _
"" & @CRLF & _
"# decimal vs. octal mix" & @CRLF & _
"http://172.031.33.33" & @CRLF & _
"http://172.021.133.01" & @CRLF & _
"" & @CRLF & _
"# octal - not supported here" & @CRLF & _
"http://0254.0021.0062.0041 # Should not fire" & @CRLF & _
"" & @CRLF & _
"# link-local addresses IPv4" & @CRLF & _
"http://169.254.1.0" & @CRLF & _
"http://169.254.254.255" & @CRLF & _
"" & @CRLF & _
"# link-local addresses IPv6" & @CRLF & _
"http://fe90:1234::/64" & @CRLF & _
"http://feaf:ffff::/128" & @CRLF & _
"http://febf:ffff:ffff:ffff:ffff:ffff:ffff:ffff" & @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