// 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)Booking Voucher Number: (?<number>\d\d\d\d\d\d\d\d\d\d)|(Guest Name : (?<name>\w\w.*))|(Check In Date : (?<date>\d{4}-\d{2}-\d{2}))|(Check Out Date : (?<Outdate>\d{4}-\d{2}-\d{2}))|(Number of Rooms : (?<RoomNumbers>)\d.*)|(Special Request : (?<SRQST>\w.*))|(paid for Guests: (?<PfG>)\d.*)|(Room Type : (?<RoomType>)\w.*)").unwrap();
let string = "Booking Voucher Number: 2052892268
Guest Name : Maxie Dibbert
Check In Date : 2018-11-09
Check Out Date : 2018-11-10
Number of Rooms : 14
Booking Type : Pay At Hotel Amount To Be Collected : 91.2 (SOD)
Special Request : NA
Breakfast Included: No Breakfast
paid for Guests: 0
Room Type : Single Bed in Female Dormitory
";
// 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/