#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)^(?P<ID>[A-Z][A-Z0-9]{3})?(?P<REF1>(?:(?!//).)+)(//(?P<REF2>.+))?(\n?(?P<EXTRA>.+))?$"
Local $sString = "TEX1CNS0P5-AA//CAT-523-VID-00EOS-0" & @CRLF & _
"XUX PETER LAB RANDOM TEXT DM5." & @CRLF & _
"" & @CRLF & _
"TEX2BFTBSH9999SBRT2L" & @CRLF & _
"RATRACE201" & @CRLF & _
"" & @CRLF & _
"TEX3GWS0P2-AA//D-14839048-99-3" & @CRLF & _
"THERE WAS 200 COALS IN HIS STOCKING." & @CRLF & _
"" & @CRLF & _
"TEX4POF OF 20/03/09//CAT342134832489" & @CRLF & _
"P/O:1600 PARK AVENUE"
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