#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?x)" & @CRLF & _
"(?(DEFINE)" & @CRLF & _
" (?<M>" & @CRLF & _
" (?=" & @CRLF & _
" (?=\w*+\W++((?>\w*?(?P=c))))" & @CRLF & _
" (?>\w*?(?P=c)(*COMMIT)(?=\w*+\W++\g{-1}((?>\g{-1}?+\w*?(?P=c)))))*+" & @CRLF & _
" )" & @CRLF & _
" )" & @CRLF & _
")" & @CRLF & _
"\b(?:(?<c>\w)(?&M)(?=\w*+\W++(\g{-1}?+\w)))++\W++\g{-1}\b"
Local $sString = "fourth thourf very veery vry very veryy rsun urns a a this is not pann pout toop topo" & @CRLF & _
"now we go with smart trams maps amps because declamations anecdotalism" & @CRLF & _
"reoccupation cornucopiate" & @CRLF & _
"" & @CRLF & _
"aaab bbba abab babb" & @CRLF & _
"" & @CRLF & _
"aaab bbba" & @CRLF & _
"" & @CRLF & _
"abab abbb" & @CRLF & _
"" & @CRLF & _
"bbaa bbba" & @CRLF & _
"" & @CRLF & _
"bbaa abab"
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