#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)^(?:\[[^\]\[\n]*\]\s+)?(?<name>[^)(\n]*)\s*(\((?!not|unus)[^)(\n]*\))?"
Local $sString = "[Example] öäüß asdf 1234 (1aö)" & @CRLF & _
"[Red] Panda (It's so cute)" & @CRLF & _
"[Red] The Panda (It's so cute)," & @CRLF & _
"[Red] what Panda (It's so cute) (not necessary)," & @CRLF & _
"[Red] it's a Panda (It's so cute) (unusual)," & @CRLF & _
"[Yellow] Leopard (the big one)" & @CRLF & _
"[Yellow] The Leopard (the big one)," & @CRLF & _
"[Yellow] what Leopard (the big one) (not needed)," & @CRLF & _
"[Yellow] it's a Leopard (the big one) (unusual)," & @CRLF & _
"[Green] Dragon (Fire? It's hot!)" & @CRLF & _
"[Green] The Dragon (Fire? It's hot!)," & @CRLF & _
"[Green] what Dragon (Fire? It's hot!) (not usual)," & @CRLF & _
"[Green] it's a Dragon (Fire? It's hot!) (unusual)," & @CRLF & _
"[Blue] Snake (zzzZZZzzzZZZ)" & @CRLF & _
"[Blue] The Snake (zzzZZZzzzZZZ)," & @CRLF & _
"[Blue] what Snake (zzzZZZzzzZZZ) (not beautiful)," & @CRLF & _
"[Blue] it's a Snake (zzzZZZzzzZZZ) (unusual)," & @CRLF & _
"Panda (It's so cute)" & @CRLF & _
"The Panda (It's so cute)," & @CRLF & _
"what Panda (It's so cute) (not necessary)," & @CRLF & _
"it's a Panda (It's so cute) (unusual)," & @CRLF & _
"Leopard (the big one)" & @CRLF & _
"The Leopard (the big one)," & @CRLF & _
"what Leopard (the big one) (not usual)," & @CRLF & _
"it's a Leopard (the big one) (unusual)," & @CRLF & _
"Dragon (Fire? It's hot!)" & @CRLF & _
"The Dragon (Fire? It's hot!)," & @CRLF & _
"what Dragon (Fire? It's hot!) (not necessary)," & @CRLF & _
"it's a Dragon (Fire? It's hot!) (unusual)," & @CRLF & _
"Snake (zzzZZZzzzZZZ)" & @CRLF & _
"The Snake (zzzZZZzzzZZZ)," & @CRLF & _
"what Snake (zzzZZZzzzZZZ) (not beautiful)," & @CRLF & _
"it's a Snake (zzzZZZzzzZZZ) (unusual)," & @CRLF & _
"Panda" & @CRLF & _
"The Panda," & @CRLF & _
"what Panda (not necessary)," & @CRLF & _
"it's a Panda (unusual)," & @CRLF & _
"Leopard" & @CRLF & _
"The Leopard," & @CRLF & _
"what Leopard (not needed)," & @CRLF & _
"it's a Leopard (unusual)," & @CRLF & _
"Dragon" & @CRLF & _
"The Dragon," & @CRLF & _
"what Dragon (not usual)," & @CRLF & _
"it's a Dragon (unusual)," & @CRLF & _
"Snake " & @CRLF & _
"The Snake ," & @CRLF & _
"what Snake (not beautiful)," & @CRLF & _
"it's a Snake (unusual),"
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