#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "^ISA(?:[^*]*[*][^*]*){8}\*(\d+)\* "
Local $sString = "ISA *00* *00* *ZZ*SOME STRING *ZZ*99999999 *130605* 2239*|*00501*000000001*0*P*>" & @CRLF & _
"" & @CRLF & _
"REF*TJ*12345677*" & @CRLF & _
"" & @CRLF & _
"REF*PQ*23432211" & @CRLF & _
"" & @CRLF & _
"LX*1"
Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYFULLMATCH)
; 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