#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "\v+(?=To:)"
Local $sString = "To: ab@domain.tld" & @CRLF & _
"Subject: Der Betreff" & @CRLF & _
"From: xp@domain.tld" & @CRLF & _
"Reply-To: xp@domain.tld" & @CRLF & _
"" & @CRLF & _
"Hier kommt meine Nachricht" & @CRLF & _
"" & @CRLF & _
"To: ab@domain.tld" & @CRLF & _
"Subject: Der Betreff" & @CRLF & _
"From: xp@domain.tld" & @CRLF & _
"Reply-To: xp@domain.tld" & @CRLF & _
"" & @CRLF & _
"Hier kommt meine Nachricht" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"To: ab@domain.tld" & @CRLF & _
"Subject: Der Betreff" & @CRLF & _
"From: xp@domain.tld" & @CRLF & _
"Reply-To: xp@domain.tld" & @CRLF & _
"" & @CRLF & _
"Hier kommt meine Nachricht"
Local $sSubst = "_"
Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst)
MsgBox($MB_SYSTEMMODAL, "Result", $sResult)
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