// 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"(?i)(NUMBER[(](\d{1,3},\d)[)])|(NUMBER[(]((\d{1,3})|(\d{1,3}[,]\d))[)]((?=\/DECIMAL)|(?=\/PERCENTAGE)).*)").unwrap();
let string = "NUMBER(12)
NUMBER(12)/NUMBER
NUMBER(1)
NUMBER(1)/NUMBER
(100)
DATATYPE=NUMBER
NUMBER
NUMBER()
NUMBER(10,2)/PERCENTAGE
NUMBER(12)/DECIMAL
NUMBER(12,4)
NUMBER(13,4)
NUMBER(15)/DECIMAL
NUMBER(15,2)
NUMBER(16)/DECIMAL
NUMBER(10,3)/DECIMAL
NUMBER(3)/DECIMAL
NUMBER(3)/PERCENTAGE
NUMBER(4)/DECIMAL
NUMBER(4,1)
NUMBER(4,2)
NUMBER(5)/DECIMAL
NUMBER(5)/PERCENTAGE
NUMBER(5,2)
NUMBER(5,2)/PERCENTAGE
NUMBER(6)/DECIMAL
NUMBER(7)/DECIMAL
NUMBER(8)/DECIMAL
NUMBER/
NUMBER/CURRENCY
NUMBER/DECIMAL
NUMBER/IFS CURRENCY
NUMBER/INVISIBLE
NUMBER/NUMBER
NUMBER/PERCENTAGE
NUMBER/UPPERCASE
NUMBER=
Number
number
";
// 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/