#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)(^.*(?<=\bobj)\s*\R)[\s\S]*?\/Form[\s\S]*?^(stream\s*^)[\s\S]*?^(endstream\s+endobj)"
Local $sString = "40 0 obj " & @CRLF & _
"<<" & @CRLF & _
"/PieceInfo " & @CRLF & _
"/Subtype /Form" & @CRLF & _
"/Resources " & @CRLF & _
"<<" & @CRLF & _
"/Font " & @CRLF & _
"<<" & @CRLF & _
"/Fm1 35 0 R" & @CRLF & _
">>" & @CRLF & _
">>" & @CRLF & _
"/Type /XObject" & @CRLF & _
"/BBox [0 -22.5 131.05 0]" & @CRLF & _
"/Length 601" & @CRLF & _
"/Matrix [1 0 0 1 0 0]" & @CRLF & _
">>" & @CRLF & _
"stream" & @CRLF & _
" . . ." & @CRLF & _
" A bunch of compressed gibberish here" & @CRLF & _
" . . ." & @CRLF & _
"endstream " & @CRLF & _
"endobj"
Local $sSubst = "\1\2\3"
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