package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^[ \t]*(?>etaLearnW_enabled)[ \t]?=[ \t]?(?<etaLearnW_enabled>[01])[ \t]*[ \t]*;?`)
var 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;`
for i, match := range re.FindAllString(str, -1) {
fmt.Println(match, "found at index", i)
}
}
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 Golang, please visit: https://golang.org/pkg/regexp/