#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)^([^"\s=]+)=('{[\s\S]*?\n}'|.*)"
Local $sString = "# IN TOTAL, THE REGEX SHOULD MATCH 4 KEY-VALUE PAIRS FROM THIS FILE." & @CRLF & _
"KEY1='{" & @CRLF & _
" "string" = {" & @CRLF & _
" "key" = "value"," & @CRLF & _
" "key" = "value"" & @CRLF & _
" }," & @CRLF & _
" "string" = {" & @CRLF & _
" "key" = "value"," & @CRLF & _
" "key" = "value"" & @CRLF & _
" }" & @CRLF & _
"}'" & @CRLF & _
"" & @CRLF & _
"# DO NOT MATCH ON COMMENTS, EVEN THOSE WITH X=Y in them." & @CRLF & _
"" & @CRLF & _
"# ALSO IGNORE THIS COMMENT, AND NEW LINES AROUND." & @CRLF & _
"" & @CRLF & _
"KEY2=SOME_TEXT" & @CRLF & _
"KEY3="SOME_MORE_TEXT"" & @CRLF & _
"KEY4='EVEN_MORE_TEXT'"
Local $sSubst = "PREFIX_\1: \2"
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