#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?mi)^\s*Failed\s(.*)([\s\S]*?)(Stack\sTrace:\s*at\s)(.*)\s+in\s+(.*):line\s+(\d+)\s*$"
Local $sString = "Test run for /home/runner/work/Library/Library.Tests/bin/Debug/net7.0/Library.Tests.dll (.NETCoreApp,Version=v7.0)" & @CRLF & _
"Microsoft (R) Test Execution Command Line Tool Version 17.7.0-preview-23364-03+bc17bb9693cfc4778ded51aa0ab7f1065433f989 (x64)" & @CRLF & _
"Copyright (c) Microsoft Corporation. All rights reserved." & @CRLF & _
"" & @CRLF & _
"Starting test execution, please wait..." & @CRLF & _
"A total of 1 test files matched the specified pattern." & @CRLF & _
"[xUnit.net 00:00:00.55] Library.Tests.UnitTest1.DeliberateFail2 [FAIL]" & @CRLF & _
"[xUnit.net 00:00:00.56] Library.Tests.UnitTest1.DeliberateFail1 [FAIL]" & @CRLF & _
" Failed Library.Tests.UnitTest1.DeliberateFail2 [< 1 ms]" & @CRLF & _
" Error Message:" & @CRLF & _
" System.Exception : Error message" & @CRLF & _
" Stack Trace:" & @CRLF & _
" at Library.Tests.UnitTest1.DeliberateFail2() in /home/runner/work/Library/Library.Tests/UnitTest1.cs:line 30" & @CRLF & _
" at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)" & @CRLF & _
" at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)" & @CRLF & _
" Failed Library.Tests.UnitTest1.DeliberateFail1 [< 1 ms]" & @CRLF & _
" Error Message:" & @CRLF & _
" Assert.True() Failure" & @CRLF & _
"Expected: True" & @CRLF & _
"Actual: False" & @CRLF & _
" Stack Trace:" & @CRLF & _
" at Library.Tests.UnitTest1.DeliberateFail1() in /home/runner/work/Library/Library.Tests/UnitTest1.cs:line 27" & @CRLF & _
" at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)" & @CRLF & _
" at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)" & @CRLF & _
"Results File: /home/runner/work/Library/Library.Tests/TestResults/test-results.trx" & @CRLF & _
"" & @CRLF & _
"Failed! - Failed: 2, Passed: 133, Skipped: 0, Total: 135, Duration: 549 ms - Library.Tests.dll (net7.0)" & @CRLF & _
"Error: Process completed with exit code 1."
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