// 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"Level>(\d+)<\/tank").unwrap();
let string = "This XML file does not appear to have any style information associated with it. The document tree is shown below.
<seqSmartbox xmlns=\"http://tecson.dev.oilview.de/gateway/xsd\" xmlns:xsi=\"http://www.w3.org/2000/10/XMLSchema-instance\" xsi:schemaLocation=\"http://tecson.dev.oilview.de/gateway/xsd/smartbox.xsd\">
<seqHeader>
<indication>Manuelle Abfrage</indication>
<authCode>03B41236A899</authCode>
<devOperator/>
<devLocation/>
<devID>2-852</devID>
<devVersion>V6.02</devVersion>
</seqHeader>
<seqData>
<seqTanks>
<tankNumber>1</tankNumber>
<tankName>Heizöl</tankName>
<seqTankLevel>
<tankLevel>490</tankLevel>
<tankUnit>L</tankUnit>
</seqTankLevel>
<tankPercent>5</tankPercent>
<seqTankSize>
<tankSize>10000</tankSize>
<tankUnit>L</tankUnit>
</seqTankSize>
<seqTankClear>
<tankClearance>9010</tankClearance>
<tankUnit>L</tankUnit>
</seqTankClear>
</seqTanks>
</seqData>
<seqPara>
<para1>30</para1>
<para2>15</para2>
<para4>0</para4>
<para5>5</para5>
<para9>0</para9>
</seqPara>
</seqSmartbox>";
// result will be an iterator over tuples containing the start and end indices for each match in the string
let result = regex.captures_iter(string);
for mat in result {
println!("{:?}", mat);
}
}
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/