// 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)^(?:\d\h+|[\d.]*[A-Z][A-Z\d.]*\h+)*[A-Z]{3,}").unwrap();
let string = "ID.4 ESTATE 109kW City Pure 52kWh 5dr Auto
XC40 DIESEL ESTATE 2.0 D4 [190] Inscription Pro 5dr AWD Gea+
RAPID DIESEL HATCHBACK 1.6 TDI CR Elegance 5dr
MODEL 3 120kW LONG RANGE AWD
V40 DIESEL HATCHBACK D2 [120] Momentum 5dr Geartronic
V60 DIESEL SPORTSWAGON 2.0 D4 [190] R DESIGN Plus 5dr Auto
X3 ESTATE xDrive M40i 5dr Auto
C CLASS DIESEL SALOON C250 BlueTEC SE 4dr Auto
A CLASS DIESEL HATCHBACK A180d Sport Executive 5dr Auto
2 SERIES COUPE 218i Sport 2dr [Nav] Step Auto
HILUX SPECIAL EDITIONS Invincible X Ltd Ed D/Cab P/Up 2.4 D+
C3 PICASSO 1.6 BlueHDi Platinum 5dr
C3 HATCHBACK 1.2 PureTech 82 Flair 5dr
XC40 DIESEL ESTATE XC40
1";
// 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/