#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?s)(?(DEFINE)(?'value'(?:\N*(?:\n(?:(?: {8}|\t)\N*))*)))\s*pool: (?'pool'\g'value')\n\s*state: (?'state'\g'value')\n((?:\s*status: (?'status'\g'value')\n)?(?:\s*action: (?'action'\g'value')\n)?\s*scan: (?'scan'\g'value')\n)?\s*config:\n\n(?'config'\g'value')\n\s*errors: (?'errors'\g'value')"
Local $sString = " pool: zfs" & @CRLF & _
" state: ONLINE" & @CRLF & _
"config:" & @CRLF & _
"" & @CRLF & _
" NAME STATE READ WRITE CKSUM" & @CRLF & _
" zfs ONLINE 0 0 0" & @CRLF & _
" ata-HGST_HTS725050A7E630_TF655AY92LL99L ONLINE 0 0 0" & @CRLF & _
"" & @CRLF & _
"errors: No known data errors"
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