const regex = new RegExp('(?mi)((?:password=|user=)[^\\n]*$|\\<property key=\\"variableNames\\"\\/\\>\\n|\\<property key=\\"variableValues\\"\\/\\>\\n)', 'g')
const str = `<maplayer simplifyAlgorithm="0" minimumScale="0" maximumScale="2500" simplifyDrawingHints="0" readOnly="0" minLabelScale="0" maxLabelScale="1e+08" simplifyDrawingTol="1" geometry="Point" simplifyMaxScale="1" type="vector" hasScaleBasedVisibilityFlag="1" simplifyLocal="1" scaleBasedLabelVisibilityFlag="0">
<id></id>
<datasource>port=1521 user=test_user password=test_passwd</datasource>
<keywordList>
<value></value>
</keywordList>
<featformsuppress>0</featformsuppress>
<editorlayout>generatedlayout</editorlayout>
<widgets/>
<conditionalstyles>
<rowstyles/>
<fieldstyles/>
</conditionalstyles>
</maplayer>
</projectlayers>
<properties>
<Variables>
<variableNames type="QStringList">
<value>paswd</value>
<value>user</value>
</variableNames>
<variableValues type="QStringList">
<value>5zdgf</value>
<value>dgdgdgfdg</value>
</variableValues>
</Variables>
<customproperties>
<property key="labeling/textColorR" value="0"/>
<property key="labeling/textTransp" value="0"/>
<property key="labeling/upsidedownLabels" value="0"/>
<property key="labeling/useSubstitutions" value="false"/>
<property key="labeling/wrapChar" value=""/>
<property key="labeling/xOffset" value="0"/>
<property key="labeling/yOffset" value="0"/>
<property key="labeling/zIndex" value="0"/>
<property key="variableNames"/>
<property key="variableValues"/>
</customproperties>`;
const subst = ``;
// The substituted value will be contained in the result variable
const result = str.replace(regex, subst);
console.log('Substitution result: ', result);
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 JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions