#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?xm)^" & @CRLF & _
"(?:OOO) # "OOO"" & @CRLF & _
"(ABC|DEF) # "ABC" or "DEF"" & @CRLF & _
"(RR|AA|DD|EE) # "RR" or "AA" or "DD" ior :"EE)" & @CRLF & _
"(" & @CRLF & _
" (?:AAA|BBC|CCC)(?=\d{3}\b) # "AAA" or "BBB" or "CCC" if followed by 3 digits" & @CRLF & _
" | # or" & @CRLF & _
" (?:ZZ|XX|YY)(?=\d{2}\b) # "ZZ" or "XX" or "YY" if followed by 2 digits" & @CRLF & _
")" & @CRLF & _
".* # anything up to the end" & @CRLF & _
"$"
Local $sString = "OOODEFDDAAA011" & @CRLF & _
"OOODEFDDZZ01" & @CRLF & _
"OOODEFDDZZ011" & @CRLF & _
"OOODEFDDZZ01 words at the end?"
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