mirror of
https://github.com/k8sgpt-ai/k8sgpt.git
synced 2025-09-11 20:19:44 +00:00
fix: improve ReplaceIfMatch regex
Signed-off-by: Matthis Holleville <matthish29@gmail.com>
This commit is contained in:
@@ -110,9 +110,9 @@ func MaskString(input string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ReplaceIfMatch(text string, pattern string, replacement 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) {
|
if re.MatchString(text) {
|
||||||
text = re.ReplaceAllString(text, replacement+" ")
|
text = re.ReplaceAllString(text, replacement)
|
||||||
}
|
}
|
||||||
return text
|
return text
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user