#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?s)(TEST_CASE_NAME.*?:(.*?)\n.*?PRIORITY.*?:(?!P3)(\w\d).*?=cut)"
Local $sString = "=head2 Gen_001" & @CRLF & _
"" & @CRLF & _
"TEST_CASE_NAME :GEN_001" & @CRLF & _
"PRIORITY :P0" & @CRLF & _
"RELEASE_INTRODUCED :7.4 AUTOMATED :YES" & @CRLF & _
"" & @CRLF & _
"STEP_NAME : step1" & @CRLF & _
"STEP_DESC :Example desc for understanding STEP_RESULT :Example result for understanding" & @CRLF & _
"" & @CRLF & _
"=cut" & @CRLF & _
"" & @CRLF & _
"=head2 Gen_003" & @CRLF & _
"" & @CRLF & _
"TEST_CASE_NAME :GEN_003" & @CRLF & _
"PRIORITY :P1" & @CRLF & _
"RELEASE_INTRODUCED :7.4 AUTOMATED :NO" & @CRLF & _
"" & @CRLF & _
"STEP_NAME : step1" & @CRLF & _
"STEP_DESC :Example desc for understanding second testcase" & @CRLF & _
"STEP_RESULT :Example result for understanding second testcase" & @CRLF & _
"" & @CRLF & _
"=cut" & @CRLF & _
"" & @CRLF & _
"=head2 Gen_004" & @CRLF & _
"" & @CRLF & _
"TEST_CASE_NAME :GEN_004" & @CRLF & _
"PRIORITY :P3" & @CRLF & _
"RELEASE_INTRODUCED :7.4 AUTOMATED :NO" & @CRLF & _
"" & @CRLF & _
"STEP_NAME : step1" & @CRLF & _
"STEP_DESC :Example desc for understanding third testcase" & @CRLF & _
"STEP_RESULT :Example result for understanding third testcase" & @CRLF & _
"" & @CRLF & _
"=cut"
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