#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?x)(?m)" & @CRLF & _
"(?:" & @CRLF & _
" ^ \d{2} - \d{4} [^|\r\n]* \| " & @CRLF & _
" | \G " & @CRLF & _
")" & @CRLF & _
"(?: [^|\r\n]* \| )*" & @CRLF & _
"\K " & @CRLF & _
"[\r\n]+ (?! [\r\n]* (?: ^ \d{2} - \d{4} | $ ) )" & @CRLF & _
""
Local $sString = "00-1234T|" & @CRLF & _
"Data|Commments|" & @CRLF & _
"12-3456|Some data|Notes|" & @CRLF & _
"65-8436ZZ|Data|" & @CRLF & _
"|" & @CRLF & _
"45-4576AA|Some data|Comments|" & @CRLF & _
"98-4392REV|Data|" & @CRLF & _
"|" & @CRLF & _
"00-5432|Some Data|Some Comments|" & @CRLF & _
""
Local $sSubst = "#CRLF#"
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