#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)(?s).*?(<div id="start">.*?<div id="end">)(?:(?:(?!<div id="start">).)*$)?"
Local $sString = "Stuff I dont need before" & @CRLF & _
"" & @CRLF & _
"<div id="start">" & @CRLF & _
"blablabla11" & @CRLF & _
"blablabla12" & @CRLF & _
"<div id="end">" & @CRLF & _
"" & @CRLF & _
"Stuff I dont need in the middle" & @CRLF & _
"" & @CRLF & _
"<div id="start">" & @CRLF & _
"blablabla21" & @CRLF & _
"blablabla22" & @CRLF & _
"<div id="end">" & @CRLF & _
"" & @CRLF & _
"Stuff I dont need in the middle2" & @CRLF & _
"" & @CRLF & _
"<div id="start">" & @CRLF & _
"blablabla31" & @CRLF & _
"blablabla32" & @CRLF & _
"<div id="end">" & @CRLF & _
"" & @CRLF & _
"Stuff I dont need in the end"
Local $sSubst = "$1\n\n"
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