#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?xm)^ # beginning of string" & @CRLF & _
"(?:" & @CRLF & _
" . # match a single character" & @CRLF & _
" (?=" & @CRLF & _
" .*?" & @CRLF & _
" # if we already have captured the end of the string" & @CRLF & _
" (?(1)" & @CRLF & _
" # make sure we do not go past the correct position" & @CRLF & _
" (?= .\1$ )" & @CRLF & _
" )" & @CRLF & _
" # capture the end of the string +1 character, adding to \1 every iteration" & @CRLF & _
" ( .\1?$ )" & @CRLF & _
" )" & @CRLF & _
")* # repeat" & @CRLF & _
"# the middle character follows, capture it" & @CRLF & _
"(.)"
Local $sString = "1" & @CRLF & _
"123" & @CRLF & _
"12345" & @CRLF & _
"1234567" & @CRLF & _
"123456789" & @CRLF & _
"12345678901" & @CRLF & _
"1234567890123" & @CRLF & _
"123456789012345" & @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