#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)(?m)(?<!])((#(?!#)(.*?)#(?!#))|(##(?!#)(.*?)##))"
Local $sString = "The text [.underline]#underline me# is underlined. +" & @CRLF & _
"The text [.line-through]#aaa# ist durchgestrichen." & @CRLF & _
"" & @CRLF & _
"text #just highlight#, normal tex#t#fg#f#gfg " & @CRLF & _
"" & @CRLF & _
"#ffsfsdf fdsfsd#" & @CRLF & _
"" & @CRLF & _
"TODO: wrong marking" & @CRLF & _
"" & @CRLF & _
"The *[red]##c##[green]##o##[purple]##l##[fuchsia]##o##[blue]##r##* brings contrast to the text, making it easier to read."
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