// 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"([0-9][ .]?){16}").unwrap();
let string = "Our customer usually send us some message which included their contract number. Our contract number formats are a string of 16 digits starts from 1000 (ex: 1000117030010745).
Right now our tool can recognize the contract number which are well placed using regex to find 16 digits placing right next to each other.
But the problem is, sometimes they include some special characters like dots(.), space etc... in the middle of the contract number and the number of those character are not constant. ex: 10001170.5102.1428 or 1000 11706 0056941.
Is there any regex that can matching those number out?
Thank you!";
// 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/