using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?mi)((?:password=|user=)[^\n]*$|\<property key=\""variableNames\""\/\>\n|\<property key=\""variableValues\""\/\>\n)";
string substitution = @"";
string input = @"<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>";
Regex regex = new Regex(pattern);
string result = regex.Replace(input, substitution);
}
}
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 C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx