using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^[ \t]*(?>etaLearnW_enabled)[ \t]?=[ \t]?(?<etaLearnW_enabled>[01])[ \t]*[ \t]*;?";
string input = @"%% 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;";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
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 C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx