// 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)^(?:[1-9][0-9]*?,?[0-9]{0,2}|[0](?:,[0-9]{0,2})?|)$").unwrap();
let string = "Input amount is not a string (only number 0-9)
Adwad,321 d3,232,123,A;d,aw
123456789
Separator must be \",\"
12.1
12,1
I need max 2 decimal places
17,234236
17,23
I can't accept any characters, except of numbers 0-9 and \",\"
321d,3e16
-323,3
123,45
Input amount cannot be less than 0
-1
0
0,01
Input amount has to start from a number
a31233
,321
1232
extra; does not allow \"fake/mal-formatted\" numbers
0312312
032312";
// 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/