#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)On-Demand Color:\s(\S+)(?:\n(?!On-Demand Color:|\s*Liveness-detection:).*)*\n\s*Liveness-detection: Enabled"
Local $sString = "RA#show segment-routing traffic-eng on-demand color detail | utility egrep Color -B 10" & @CRLF & _
"Sat Dec 25 11:24:22.891 JST" & @CRLF & _
"" & @CRLF & _
"SR-TE On-Demand-Color database" & @CRLF & _
"------------------------" & @CRLF & _
"" & @CRLF & _
"On-Demand Color: 20" & @CRLF & _
"--" & @CRLF & _
" Performance-measurement:" & @CRLF & _
" Reverse-path Label: Not Configured" & @CRLF & _
" Delay-measurement: Disabled" & @CRLF & _
" Liveness-detection: Enabled 《-------" & @CRLF & _
" Profile: liveness1" & @CRLF & _
" Invalidation Action: down" & @CRLF & _
" Logging:" & @CRLF & _
" Session State Change: Yes" & @CRLF & _
" Per-flow Information:" & @CRLF & _
" Default Forward Class: 0" & @CRLF & _
"On-Demand Color: 23" & @CRLF & _
"--" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
" Performance-measurement:" & @CRLF & _
" Reverse-path Label: Not Configured" & @CRLF & _
" Delay-measurement: Disabled" & @CRLF & _
" Liveness-detection: Enabled 《--------" & @CRLF & _
" Profile: liveness1" & @CRLF & _
" Invalidation Action: down" & @CRLF & _
" Logging:" & @CRLF & _
" Session State Change: Yes" & @CRLF & _
" Per-flow Information:" & @CRLF & _
" Default Forward Class: 0" & @CRLF & _
"On-Demand Color: 301"
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