#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?im)(?:^|\s)(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]+|::(ffff(:0{1,4})?:)?((25[0-5]|2[0-4]\d|1\d{0,2}|[1-9]?\d)\.){3}(25[0-5]|2[0-4]\d|1\d{0,2}|[1-9]?\d)|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|2[0-4]\d|1\d{0,2}|[1-9]?\d)\.){3}(25[0-5]|2[0-4]\d|1\d{0,2}|[1-9]?\d))(?=\s|$)" & @CRLF & _
""
Local $sString = "{1: Initial address, regex should say valid/match}" & @CRLF & _
"2001:0db8:0000:0000:0000:ff00:0042:8329" & @CRLF & _
"" & @CRLF & _
"{2: After removing all leading zeroes, regex should say valid/match}" & @CRLF & _
"2001:db8:0:0:0:ff00:42:8329" & @CRLF & _
"" & @CRLF & _
"{3: After omitting consecutive sections of zeroes, regex should say valid/match}" & @CRLF & _
"2001:db8::ff00:42:8329" & @CRLF & _
"" & @CRLF & _
"{4: The loopback address, regex should say valid/match}" & @CRLF & _
"0000:0000:0000:0000:0000:0000:0000:0001" & @CRLF & _
"" & @CRLF & _
"{5: The loopback address be abbreviated to ::1 by using both rules, regex should say valid/match}" & @CRLF & _
"::1" & @CRLF & _
"" & @CRLF & _
"{6: This should be valid, regex should say valid/match}" & @CRLF & _
"ABCD:ABCD:ABCD:ABCD:ABCD:ABCD:192.168.158.190" & @CRLF & _
"" & @CRLF & _
"{7: This should NOT be valid/match}" & @CRLF & _
"::" & @CRLF & _
"" & @CRLF & _
"{These two formats allows IPv6 applications to communicate directly with IPv4 applications, regex should say valid/match}" & @CRLF & _
"{8}" & @CRLF & _
"0:0:0:0:0:ffff:192.1.56.10" & @CRLF & _
"{9}" & @CRLF & _
"::ffff:192.1.56.10/96" & @CRLF & _
"" & @CRLF & _
"{These next two formats are used for tunneling. It allows IPv6 nodes to communicate across an IPv4 infrastructure, regex should say valid/match}" & @CRLF & _
"{10}" & @CRLF & _
"0:0:0:0:0:0:192.1.56.10" & @CRLF & _
"{11}" & @CRLF & _
"::192.1.56.10/96" & @CRLF & _
"" & @CRLF & _
"{These 4 should be valid/match}" & @CRLF & _
"{12}" & @CRLF & _
"::FFFF:129.144.52.38" & @CRLF & _
"{13}" & @CRLF & _
"::129.144.52.38" & @CRLF & _
"{14}" & @CRLF & _
"::FFFF:d" & @CRLF & _
"{15}" & @CRLF & _
"1080:0:0:0:8:800:200C:417A" & @CRLF & _
"" & @CRLF & _
"{These 4 should NOT be valid/match}" & @CRLF & _
"{16}" & @CRLF & _
"::FFFF:d.d.d" & @CRLF & _
"{17}" & @CRLF & _
"::FFFF:d.d" & @CRLF & _
"{18}" & @CRLF & _
"::d.d.d" & @CRLF & _
"{19}" & @CRLF & _
"::d.d"
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