#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)COPD\sGOLD\s([0-9])([A-Z])?\b"
Local $sString = "Infektexacerbierte COPD GOLD 2" & @CRLF & _
"COPD GOLD 2" & @CRLF & _
"COPD GOLD 3B" & @CRLF & _
"Betablocker wurden bei COPD GOLD 4 nicht verabreicht." & @CRLF & _
"" & @CRLF & _
"COPD Stadium D nach GOLD mit Emphysem" & @CRLF & _
"Risikogruppe B nach GOLD mit \rrespiratorischer Globalinsuffizi" & @CRLF & _
"Virale infektexazerbierte COPD GOLD D" & @CRLF & _
"Exazerbierte COPD mit erforderlicher intermittierender BiPAP-Beatmung bei hyperkapnischen respiratorischen Insuffizienz\rLungenemphysem, COPD Stadium GOLD 4\" & @CRLF & _
"Risikoklasse D nach GOLD mit respiratorischer Partialinsuffizienz in Ruhe" & @CRLF & _
"m II-III, Risikogruppe D nach GOLD" & @CRLF & _
"COPD Stad. II nach GOLD$" & @CRLF & _
"rt. Bei bek. COPD St. IV nach GOLD stellte sich ein prolongierte" & @CRLF & _
"Beurteilung: COPD III nach GOLD Lungenemphysem. Keine asthmoi" & @CRLF & _
"m II-III, Risikogruppe D nach GOLD" & @CRLF & _
"COPD Stad. II nach GOLD" & @CRLF & _
"Bei bek. COPD St. IV nach GOLD stellte sich ein prolongierte" & @CRLF & _
"Beurteilung: COPD III nach GOLD Lungenemphysem. Keine asthmoi" & @CRLF & _
"OPD bekannt Grad 1 bis 2 nach GOLD , antiobstruktive Therapie mi"
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