// 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"(?m)(?<=^Fuse - )[\d.\/m]+A|(?<=\s)\dA").unwrap();
let string = "Fuse - 1.25A 250V 5x20mm, Glass, Time Delay, 5/pk
Fuse - 1A 250V 5x20mm, Glass, Time Delay, 5/pk
Fuse - 20A 250V 5x20mm, Glass, Time Delay, 5/pk MDA Style
Fuse - 3/4A 250V 5x20mm, Glass, Time Delay, 5/pk MDA Style
Fuse - 340mA 250V 5x20mm, Glass, Time Delay, 5/pk MDA Style
SCR - 4A 400V T0126";
// 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/