#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?<=\W)I{1,3}(?!\w)"
Local $sString = "TEST I " & @CRLF & _
"" & @CRLF & _
"TEST II" & @CRLF & _
"" & @CRLF & _
"TEST III" & @CRLF & _
"" & @CRLF & _
"STRINGENDINGINI III " & @CRLF & _
"" & @CRLF & _
"ANOTHER TEST II" & @CRLF & _
"" & @CRLF & _
"ANOTHERI TESTI III" & @CRLF & _
"" & @CRLF & _
"Results for these should be" & @CRLF & _
"" & @CRLF & _
"I " & @CRLF & _
"" & @CRLF & _
"II" & @CRLF & _
"" & @CRLF & _
"III" & @CRLF & _
"" & @CRLF & _
"III" & @CRLF & _
"" & @CRLF & _
"II" & @CRLF & _
"" & @CRLF & _
"III"
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