// 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)(?<=Amount:\s?\$)([0-9,]+\.\d{2})|(?<=Date:\s?)(\d{2}/\d{2}/\d{4})|(?<=Invoice:\s?)(\d+)|(?<=Billing Account Name:\s?)([\w\s]+)").unwrap();
let string = "Dear Valued AdRoll Customer,
Your payment for invoice #5925702 has been processed. Please see below for additional details.
Learn more about your billing history.
-- Transaction Details --
Amount: $450.42
Date: 10/15/2024
Invoice: 5925702
Billing Account Name: RRL Exhbits
Profile(s):
Reagan Library
If you have any questions, please contact support@adroll.com.
Download Invoice PDF
Log in to AdRoll
---
If you have any questions, don’t hesitate to contact our Support team or chat with us live.";
// 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/