#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?s)^.*?\n(?=Paragraph)"
Local $sString = "Text of variable length spread across several lines Serialization-type text separated by colons (eg ABC:DEF:GHI) A date" & @CRLF & _
"" & @CRLF & _
"From: One line of text To: One or more lines Subject: One or more lines References: One or more lines" & @CRLF & _
"" & @CRLF & _
"From: One line of text To: One " & @CRLF & _
"or " & @CRLF & _
"more " & @CRLF & _
"lines Subject: One or more lines References: One or more lines" & @CRLF & _
"" & @CRLF & _
"From: One line of text To: One or more lines Subject: No references." & @CRLF & _
"" & @CRLF & _
"From: One line of text To: One or more lines Subject: One " & @CRLF & _
"or " & @CRLF & _
"more " & @CRLF & _
"lines " & @CRLF & _
"References: One or more lines" & @CRLF & _
"" & @CRLF & _
"Paragraph 1 Title: A paragraph" & @CRLF & _
"" & @CRLF & _
"Paragraph 2 Title: Another paragraph"
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