From 0f1586393b71b3bc3c0b77c6c5f1bb4ddc828d33 Mon Sep 17 00:00:00 2001 From: Roy Olav Purser Date: Sat, 15 Jan 2022 19:54:59 +0100 Subject: [PATCH] fix regex --- envconf.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/envconf.go b/envconf.go index 849a968..da14de4 100644 --- a/envconf.go +++ b/envconf.go @@ -259,7 +259,7 @@ func (c *Config) Status() (ok bool) { } func cleanKey(key string) string { - expr := regexp.MustCompile("__+") + expr := regexp.MustCompile("(?:^_+)|(?:_+(?=_))|(?:_$)") fn := func(r rune) rune { if (r >= '0' && r <= '9') || (r >= 'A' && r <= 'Z') || r == '_' { return r @@ -268,7 +268,7 @@ func cleanKey(key string) string { } key = strings.Map(fn, strings.ToUpper(key)) - return expr.ReplaceAllString(key, "_") + return expr.ReplaceAllString(key, "") } func keySplit(key string) (left string, right string, ok bool) {