From fd936ceaf725d1c1ed1f53eaa2204455dcd1e2af Mon Sep 17 00:00:00 2001 From: Matthis Holleville Date: Mon, 10 Apr 2023 23:36:43 +0200 Subject: [PATCH] fix: improve ReplaceIfMatch regex Signed-off-by: Matthis Holleville --- pkg/util/util.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/util/util.go b/pkg/util/util.go index 5d41d0dd45..ee02c1f5fd 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -110,9 +110,9 @@ func MaskString(input string) string { } func ReplaceIfMatch(text string, pattern string, replacement string) string { - re := regexp.MustCompile(fmt.Sprintf(`%s(\b\s)`, pattern)) + re := regexp.MustCompile(fmt.Sprintf(`%s(\b)`, pattern)) if re.MatchString(text) { - text = re.ReplaceAllString(text, replacement+" ") + text = re.ReplaceAllString(text, replacement) } return text }