#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?mi)(\<manufacturer>([^<]*)<\/manufacturer>)(\s*)(\<item_category>)(?:\2\s*)?([^<]*)(<\/item_category>)"
Local $sString = "<vehicle>" & @CRLF & _
" <manufacturer>JCB</manufacturer>" & @CRLF & _
" <item_category>JCB Tractors</item_category>" & @CRLF & _
"</vehicle>" & @CRLF & _
"<vehicle>" & @CRLF & _
" <manufacturer>Caterpillar</manufacturer>" & @CRLF & _
" <item_category>Digger</item_category>" & @CRLF & _
"</vehicle>" & @CRLF & _
"<vehicle>" & @CRLF & _
" <manufacturer>Caterpillar</manufacturer>" & @CRLF & _
" <item_category>Caterpillar Digger</item_category>" & @CRLF & _
"</vehicle>"
Local $sSubst = "$1$2$3$4$5$6"
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