// include the latest version of the regex crate in your Cargo.toml
extern crate regex;
use regex::Regex;
fn main() {
let regex = Regex::new(r#"(?mi)((?:password=|user=)[^\n]*$|\<property key=\"variableNames\"\/\>\n|\<property key=\"variableValues\"\/\>\n)"#).unwrap();
let string = "<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>";
let substitution = "";
// result will be a String with the substituted value
let result = regex.replace_all(string, substitution);
println!("{}", 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 Rust, please visit: https://docs.rs/regex/latest/regex/