#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "\[(?<tag>[^\]]+)]\s*(?<content>[\w\W]+?)\s*\[\/\1]"
Local $sString = "[SLUG]ghana-cocoa-supply-shortfall-impacts-traders[/SLUG]" & @CRLF & _
"" & @CRLF & _
"[TITLE]Sweet Trouble: Ghana's Cocoa Shortfall Leaves Traders in a Bitter Spot[/TITLE]" & @CRLF & _
"" & @CRLF & _
"[EXCERPT]Ghana's cocoa bean delivery hiccup has traders facing a whopping $1 billion loss. Here's what happened and why it matters for your morning mocha.[/EXCERPT]" & @CRLF & _
"" & @CRLF & _
"[BODY]" & @CRLF & _
"<p>Hey there, chocolate lovers and market watchers! Grab your favorite cocoa-based snack because we've got some news that might make your wallet feel a little lighter (but hopefully not your candy bar).</p>" & @CRLF & _
"[/BODY]" & @CRLF & _
"" & @CRLF & _
"[CATEGORIES]Finance,Commodities,Global Trade[/CATEGORIES]" & @CRLF & _
"" & @CRLF & _
"[TAGS]cocoa,Ghana,commodities,trading,supplychain,chocolate[/TAGS]"
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