#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?ms)(xyz(?:(?!abc).)*?)123"
Local $sString = "abc----1" & @CRLF & _
"pqr----2" & @CRLF & _
"123----3" & @CRLF & _
"xyz----4" & @CRLF & _
"lll----5" & @CRLF & _
"pqr----6" & @CRLF & _
"123----7" & @CRLF & _
"qqq----8" & @CRLF & _
"xyz----5" & @CRLF & _
"abc----3" & @CRLF & _
"123----9"
Local $sSubst = "$1456"
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