re = /^[ \t]*(?>etaLearnW_enabled)[ \t]?=[ \t]?(?<etaLearnW_enabled>[01])[ \t]*[ \t]*;?/m
str = '%% 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;'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
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 Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html