#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?imD)^(?>(?>([a-f0-9]{1,4})(?>:(?1)){7}|(?!(?:.*[a-f0-9](?>:|$)){8,})((?1)(?>:(?1)){0,6})?::(?2)?)|(?>(?>(?1)(?>:(?1)){5}:|(?!(?:.*[a-f0-9]:){6,})(?3)?::(?>((?1)(?>:(?1)){0,4}):)?)?(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?>\.(?4)){3}))$"
Local $sString = "/*These should be valid*/" & @CRLF & _
"" & @CRLF & _
"{Initial address}" & @CRLF & _
"2001:0db8:0000:0000:0000:ff00:0042:8329" & @CRLF & _
"" & @CRLF & _
"{After removing all leading zeroes}" & @CRLF & _
"2001:db8:0:0:0:ff00:42:8329" & @CRLF & _
"" & @CRLF & _
"{After omitting consecutive sections of zeroes}" & @CRLF & _
"2001:db8::ff00:42:8329" & @CRLF & _
"" & @CRLF & _
"{The loopback address}" & @CRLF & _
"0000:0000:0000:0000:0000:0000:0000:0001" & @CRLF & _
"" & @CRLF & _
"{The loopback address be abbreviated to ::1 by using both rules}" & @CRLF & _
"::1" & @CRLF & _
"" & @CRLF & _
"{4 other valid test cases}" & @CRLF & _
"::FFFF:129.144.52.38" & @CRLF & _
"::129.144.52.38" & @CRLF & _
"::FFFF:d" & @CRLF & _
"1080:0:0:0:8:800:200C:417A" & @CRLF & _
"" & @CRLF & _
"/*These 4 should be invalid*/" & @CRLF & _
"::FFFF:d.d.d" & @CRLF & _
"::FFFF:d.d" & @CRLF & _
"::d.d.d" & @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