// 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"Manufacturer:\s(?<Manufacturer>.*)").unwrap();
let string = "002446fffd003274.2:
Label: Back Door Lock
Manufacturer: Kwikset
Model: SMARTCODE_DEADBOLT_5
Firmware version: 0x3071cb06
Hardware version: 3
User Properties:
NearEndRssi: -41
NearEndLqi: 243
label: Back Door Lock
deadboltJammed: false
Battery Operated: True
Voltage: 5.8V
FE radio: -67/254
NE radio: -41/243
Date added: Thu Oct 27 08:02:42 CDT 2016
Date of last communication: Mon Feb 13 14:15:14 CST 2017
In Communication Failure: false
In firmware upgrade failure: false
Firmware upgrade available: false
Is Locked: true
Max Users: 30
Operation Mode: normal";
// 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/