// 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)(.+):\s*TextConst\s*ENU\s*=\s*'(.*)',\s*ENG\s=\s'(.*)';").unwrap();
let string = "Regular Expression No.1 --> (.+):\\s*TextConst\\s*ENU\\s*=\\s*'(.*)',\\s*ENG\\s=\\s'(.*)';
------------------------------------------------------------------------------------
TxtLineText: TextConst ENU = 'Line %1: ', ENG = 'Line %1: ';
TxtNoLinesToProcess: TextConst ENU = 'There are no lines to process', ENG = 'There are no lines to process';
Regular Expression No.2 --> (.+):\\s*TextConst\\s*ENU\\s*='(.*)'\\s*,\\s*ENG='(.*)'\\s*;
-----------------------------------------------------------------------------------
TxtPurchaseWorksheetNosCode : TextConst ENU='PURCH WKSH',ENG='PURCH WKSH';
TxtPurchaseWorksheetNosDescription : TextConst ENU='Purchase Worksheet',ENG='Purchase Worksheet';
TxtPurchaseWorksheetNosStartingNo : TextConst ENU='PW000001',ENG='PW000001';
TxtSalesWorksheetNosCode : TextConst ENU='SALES WKSH',ENG='SALES WKSH';
TxtSalesWorksheetNosDescription : TextConst ENU='Sales Worksheet',ENG='Sales Worksheet';
TxtSalesWorksheetNosStartingNo : TextConst ENU='SW000001',ENG='SW000001';";
// 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/