// 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)\b(?!\w\s{1,2}\w+)\w(\w|\s){3}\d{10}").unwrap();
let string = " a regular expression using C#/.Net that matches 1-4 alphanumerics followed by spaces, followed by 10 digits.
The catch is the number of spaces plus the number of alphanumerics must equal 4,
and the spaces must follow the alphanumerics, not be interspers
abcd1234567890 y
a 1234567890 y
ab 1234567890 y
1 1234567890 y
1 1234567890 n
1 1234567890 n
11234567890 n
a c 1234567890 n
a d1234567890 n
abcd 1234567890 n
";
// 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/