#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?:(?!<(?:field|exclGroup)(?!\w)(?>"[\S\s]*?"|'[\S\s]*?'|(?:(?!\/>)[^>])?)+>)[\S\s])*(?><(field|exclGroup)(?=(?:[^>"']|"[^"]*"|'[^']*')*?\sname\s*=\s*(?:(['"])([\S\s]*?)\2))\s+(?>"[\S\s]*?"|'[\S\s]*?'|(?:(?!\/>)[^>])?)+>)(?:(?&core)|)<\/\1\s*>(?:(?!<(?:field|exclGroup)(?!\w)(?>"[\S\s]*?"|'[\S\s]*?'|(?:(?!\/>)[^>])?)+>)[\S\s])*(?(DEFINE)(?<core>(?>(?><([\w:]+)(?>"[\S\s]*?"|'[\S\s]*?'|(?:(?!\/>)[^>])?)+>)(?:(?&core)|)<\/\5\s*>|(?!<\/[\w:]+\s*>)(?>[\S\s]))+))"
Local $sString = "<field xmlns="http://www.xfa.org/schema/xfa-template/2.8/" y="0in" x="0.343mm" w="8.881pt" h="9.108pt" name="detcon_recreation_only">" & @CRLF & _
" <ui>" & @CRLF & _
" <checkButton size="8.881pt">" & @CRLF & _
" <border>" & @CRLF & _
" <edge stroke="lowered"/>" & @CRLF & _
" <fill/>" & @CRLF & _
" </border>" & @CRLF & _
" </checkButton>" & @CRLF & _
" </ui>" & @CRLF & _
" <font size="0pt" typeface="Adobe Pi Std"/>" & @CRLF & _
" <para vAlign="middle"/>" & @CRLF & _
" <value>" & @CRLF & _
" <text>0</text>" & @CRLF & _
" </value>" & @CRLF & _
" <items>" & @CRLF & _
" <text>1</text>" & @CRLF & _
" <text>0</text>" & @CRLF & _
" <text/>" & @CRLF & _
" </items>" & @CRLF & _
"</field>" & @CRLF & _
"<field xmlns="http://www.xfa.org/schema/xfa-template/2.8/" name="detcon_special_housing" y="5.393mm" w="27.94mm" h="4.134mm" x="0.343mm">" & @CRLF & _
" <ui>" & @CRLF & _
" <choiceList>" & @CRLF & _
" <border>" & @CRLF & _
" <edge stroke="lowered"/>" & @CRLF & _
" </border>" & @CRLF & _
" <margin/>" & @CRLF & _
" </choiceList>" & @CRLF & _
" </ui>" & @CRLF & _
" <font typeface="Arial Narrow" size="6pt"/>" & @CRLF & _
" <margin topInset="0mm" bottomInset="0mm" leftInset="0mm" rightInset="0mm"/>" & @CRLF & _
" <para vAlign="middle"/>" & @CRLF & _
" <value>" & @CRLF & _
" <text>NA</text>" & @CRLF & _
" </value>" & @CRLF & _
" <items>" & @CRLF & _
" <text>Not Applicable</text>" & @CRLF & _
" <text>Hotel Component</text>" & @CRLF & _
" </items>" & @CRLF & _
" <items save="1" presence="hidden">" & @CRLF & _
" <text>NA</text>" & @CRLF & _
" <text>HC</text>" & @CRLF & _
" </items>" & @CRLF & _
"</field>" & @CRLF & _
"<exclGroup xmlns="http://www.xfa.org/schema/xfa-template/2.8/" name="detcon_photo_taken" x="0in" y="0in">" & @CRLF & _
" <?templateDesigner itemValuesSpecified 1?>" & @CRLF & _
" <field w="12.446mm" h="3.825mm" name="lb_yes">" & @CRLF & _
" <ui>" & @CRLF & _
" <checkButton size="1.7639mm" shape="round">" & @CRLF & _
" <border>" & @CRLF & _
" <?templateDesigner StyleID apcb1?>" & @CRLF & _
" <edge/>" & @CRLF & _
" <fill/>" & @CRLF & _
" </border>" & @CRLF & _
" </checkButton>" & @CRLF & _
" </ui>" & @CRLF & _
" <font typeface="Myriad Pro"/>" & @CRLF & _
" <margin leftInset="1mm" rightInset="1mm"/>" & @CRLF & _
" <para vAlign="middle"/>" & @CRLF & _
" <caption placement="right" reserve="7.698mm">" & @CRLF & _
" <para vAlign="middle" spaceAbove="0pt" spaceBelow="0pt" textIndent="0pt" marginLeft="0pt" marginRight="0pt"/>" & @CRLF & _
" <font size="8pt" typeface="Arial Narrow" baselineShift="0pt"/>" & @CRLF & _
" <value>" & @CRLF & _
" <text>YES</text>" & @CRLF & _
" </value>" & @CRLF & _
" </caption>" & @CRLF & _
" <value>" & @CRLF & _
" <text xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>" & @CRLF & _
" </value>" & @CRLF & _
" <items>" & @CRLF & _
" <text>1</text>" & @CRLF & _
" </items>" & @CRLF & _
" </field>" & @CRLF & _
" <field w="28.702mm" h="3.825mm" name="lb_no" x="13.233mm">" & @CRLF & _
" <ui>" & @CRLF & _
" <checkButton size="1.7639mm" shape="round">" & @CRLF & _
" <border>" & @CRLF & _
" <?templateDesigner StyleID apcb1?>" & @CRLF & _
" <edge/>" & @CRLF & _
" <fill/>" & @CRLF & _
" </border>" & @CRLF & _
" </checkButton>" & @CRLF & _
" </ui>" & @CRLF & _
" <font typeface="Myriad Pro"/>" & @CRLF & _
" <margin leftInset="1mm" rightInset="1mm"/>" & @CRLF & _
" <para vAlign="middle"/>" & @CRLF & _
" <caption placement="right" reserve="23.954mm">" & @CRLF & _
" <para vAlign="middle" spaceAbove="0pt" spaceBelow="0pt" textIndent="0pt" marginLeft="0pt" marginRight="0pt"/>" & @CRLF & _
" <font size="8pt" typeface="Arial Narrow" baselineShift="0pt"/>" & @CRLF & _
" <value>" & @CRLF & _
" <text>NO (see comments)</text>" & @CRLF & _
" </value>" & @CRLF & _
" </caption>" & @CRLF & _
" <value>" & @CRLF & _
" <text xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>" & @CRLF & _
" </value>" & @CRLF & _
" <items>" & @CRLF & _
" <text>0</text>" & @CRLF & _
" </items>" & @CRLF & _
" </field>" & @CRLF & _
" <border>" & @CRLF & _
" <edge presence="hidden"/>" & @CRLF & _
" </border>" & @CRLF & _
" <?templateDesigner expand 1?></exclGroup>"
Local $sSubst = "VALUES (12345,"$3","/Tx", "", "N", "Y"),\r\n"
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