// 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"\b\d{1,3}(?:,\d{2,3})*(?:,\d{3})*(?:\.\d+)?\b").unwrap();
let string = "problem satatement is to get all the amount despite of inconsistencies in comma or dollar sign also I need to exclude year from that (if no pattern can be made asssume to get all the amount greater than 3000)
$ 1,000,000.6522
$ 3,500,000
90,00,00,000
5000000
200
200,000
20,00,000
1,000
$ 4,000,000 for the 2023
800,000
90.65
5,555
5000
2021 --------this should be excluded from the pattern
89jfe90ABI900 ----this also should be excluded from the pattern";
// result will be a tuple containing the start and end indices for the first match in the string
let result = regex.captures(string);
let (start, end) = match result {
Some((s, e)) => (s, e),
None => {
// ...
}
};
println!("{}", &string[start, end]);
}
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/