#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?mix)^NoticeText:(?:(?!\nNoticeText:)[\s\S])*\n\s+Text\s*\[str\]\s*=\s*"([^"]*)"(?:(?!\nNoticeText:)[\s\S])*"
Local $sString = "NoticeText:" & @CRLF & _
" NoticeType [str] = USER_TYPING_ON" & @CRLF & _
" Text [str] = "user is typing"" & @CRLF & _
" EventInfo:" & @CRLF & _
" PartyId [int] = 2" & @CRLF & _
" EventType [str] = MESSAGE" & @CRLF & _
" UserNickname [str] = "Michael"" & @CRLF & _
" EventId [int] = 4" & @CRLF & _
" Text [str] = "Hey, how are you?"" & @CRLF & _
" MsgCheck [str] = NONE" & @CRLF & _
" TimeOffset [int] = 23" & @CRLF & _
" UserType [str] = AGENT" & @CRLF & _
"NoticeText:" & @CRLF & _
" NoticeType [str] = USER_TYPING_ON" & @CRLF & _
" EventInfo:" & @CRLF & _
" PartyId [int] = 1" & @CRLF & _
" EventType [str] = MESSAGE" & @CRLF & _
" UserNickname [str] = "Bob Smith"" & @CRLF & _
" EventId [int] = 6" & @CRLF & _
" Text [str] = "I'm good, how are you?"" & @CRLF & _
" MsgCheck [str] = NONE" & @CRLF & _
" TimeOffset [int] = 28" & @CRLF & _
" UserType [str] = CLIENT" & @CRLF & _
" MessageType [str] = "text""
Local $sSubst = "$1"
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