#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(\bBEGIN\b([\w\n]*?)\bEND\b\n)"
Local $sString = "a" & @CRLF & _
"b" & @CRLF & _
"BEGIN" & @CRLF & _
"c" & @CRLF & _
"d" & @CRLF & _
"e" & @CRLF & _
"END" & @CRLF & _
"f" & @CRLF & _
"g" & @CRLF & _
"h" & @CRLF & _
"i" & @CRLF & _
"j" & @CRLF & _
"BEGIN" & @CRLF & _
"k" & @CRLF & _
"l" & @CRLF & _
"m" & @CRLF & _
"n" & @CRLF & _
"o" & @CRLF & _
"p" & @CRLF & _
"q" & @CRLF & _
"END" & @CRLF & _
"r" & @CRLF & _
"s" & @CRLF & _
"t" & @CRLF & _
"u" & @CRLF & _
"v" & @CRLF & _
"BEGIN" & @CRLF & _
"w" & @CRLF & _
"x" & @CRLF & _
"y" & @CRLF & _
"END" & @CRLF & _
"z"
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