#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)(\b(pre1|pre2)?WORD(suf1|suf2)?\b)"
Local $sString = "1. Xxx xxx WORDsuf1 xxx xxx xxx." & @CRLF & _
"2. Xxx xxx WORDsuf2 xxx xxx xxx." & @CRLF & _
"3. Xxx xxx pre1WORDsuf1 xxx xxx xxx." & @CRLF & _
"4. Xxx xxx WORD xxx xxx xxx." & @CRLF & _
"5. Xxx xxx pre1WORD xxx xxx xxx." & @CRLF & _
"6. Xxx xxx pre2WORDxxx xxx xxx xxx." & @CRLF & _
"7. Xxx xxx xxxWORDxxx xxx xxx xxx." & @CRLF & _
"8. Xxx xxx pre1WORDxxxsuf1 xxx xxx xxx." & @CRLF & _
"9. Xxx xxx pre1xxxWORDsuf1 xxx xxx xxx." & @CRLF & _
"10. Xxx xxx xxxWORDxxx xxx xxx xxx."
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