// 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"(?:Product (\d{6})(\d{8}) (.{12}) (.+)\s?\*BCA)+").unwrap();
let string = "Account balance PLM051 05May2016 10:54
Actions Submenu View authorisation balance details
View available balance detailsExit
Product 40256731631234 BUSINESS A/C Zapp Innovat*BCA
Balances as at 05May2016 10:54 except where indicated
Balance 907.50Cr
Statement balance 1,059.50Cr (04May2016)
Cleared balance 907.50Cr
Interest balance 1,059.50Cr (04May2016)
Available balance 793.56Cr
Authorisation balance 793.56Cr
Other details
Account balance PLM051 05May2016 10:54
Actions Submenu View authorisation balance details
View available balance detailsExit
Product 40256731631234 BUSINESS A/C Zapp Innovat*BCA
Balances as at 05May2016 10:54 except where indicated
Balance 907.50Cr
Statement balance 1,059.50Cr (04May2016)
Cleared balance 907.50Cr
Interest balance 1,059.50Cr (04May2016)
Available balance 793.56Cr
Authorisation balance 793.56Cr
Other details
";
// 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/