#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)([^\s:\n][^:\n]*)\s+\:\s+\[\s*([^][]*)\s+]"
Local $sString = "Date : [ 2010-01-01 XX:XX:XX ] Age : [ 22 ] Sex : [ M ] : [ XXX ]" & @CRLF & _
"Height(cm) : [ 145 ] Weight(kg) : [ 56.4 ] Race : [ Hispanic ]" & @CRLF & _
"Spirometry : [ restrictive pattern ]" & @CRLF & _
"Treatment response : [ Negative ]" & @CRLF & _
"Tissue volume : [ Normal ]" & @CRLF & _
"Tissue volume" & @CRLF & _
"[ Normal RV ] " & @CRLF & _
"Diffusing capacity : [ Normal capacity ]" & @CRLF & _
"FVC Liters : [ 2.22 ] FVC Liters : [ 67 ] FVC Liters : [ 3.35 ] " & @CRLF & _
"FEV1 Liters : [ 1.96 ] FEV1 Liters : [ 66 ] FEV1 Liters : [ 2.06 ] " & @CRLF & _
"FEV1 / FVC % : [ 58 ] FEV1 / FVC % : [ 62 ]" & @CRLF & _
"DLCO mL/mmHg/min : [ 21.5 ] DLCO mL/mmHg/min : [ 102 ]" & @CRLF & _
"DLCO Adj mL/mmHg/min : [ 21.5 ] DLCO Adj mL/mmHg/min : [ 102 ]" & @CRLF & _
"RV/TLC % : [ 22 ]"
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