// 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)^[ \t]*(?>etaLearnW_enabled)[ \t]?=[ \t]?(?<etaLearnW_enabled>[01])[ \t]*[ \t]*;?").unwrap();
let string = "%% LEARNING RATES and other HYPER PARAMETERS
lambdaInfomaxTerm = 1; %coeff before logdetT'T, 0 or 1
etaLearnW_enabled = 1;
etaLearnW_enabled = 1;
% etaLearnW_enabled = 1;
%etaLearnW_enabled = 1;
etaLearnW = 1E-4;
%lambdaRidgeW = 3e-3; %going down, crashes on epoch 3888
lambdaRidgeW = 3e-2;
etaLearnK_enabled = 1;
etaLearnK = 4E-5;
%PostSlim:
%lambdaRidgeK = 3e-5; %too weak (going down fast)
%lambdaRidgeK = 3e-4; %too weak (fails at #14628)
lambdaRidgeK = 1e-3;";
// 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/