From 95b9f7d3f33da406f0c32d6b0d78d5a201af09de Mon Sep 17 00:00:00 2001 From: exhq Date: Mon, 26 Feb 2024 13:43:51 +0330 Subject: [PATCH] local programmer doesnt know what regex is --- asciiarts/asciiart.go | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/asciiarts/asciiart.go b/asciiarts/asciiart.go index 0cc7d81..d66b419 100644 --- a/asciiarts/asciiart.go +++ b/asciiarts/asciiart.go @@ -2,29 +2,19 @@ package asciiarts import ( "embed" - "strings" + "regexp" ) //go:embed *.txt var asciifiles embed.FS func GetAscii(distroID string) string { + regex, _ := regexp.Compile("{[[:upper:]]+}") asciiBuff, error := asciifiles.ReadFile(distroID + ".txt") if error != nil { asciiBuff, _ = asciifiles.ReadFile("unknown.txt") } ascii := string(asciiBuff) - ascii = strings.ReplaceAll(ascii, "{WHITE}", "") - ascii = strings.ReplaceAll(ascii, "{YELLOW}", "") - ascii = strings.ReplaceAll(ascii, "{BLUE}", "") - ascii = strings.ReplaceAll(ascii, "{LPINK}", "") - ascii = strings.ReplaceAll(ascii, "{BACKGROUND_GREEN}", "") - ascii = strings.ReplaceAll(ascii, "{NORMAL}", "") - ascii = strings.ReplaceAll(ascii, "{BLACK}", "") - ascii = strings.ReplaceAll(ascii, "{GREEN}", "") - ascii = strings.ReplaceAll(ascii, "{RED}", "") - ascii = strings.ReplaceAll(ascii, "{PINK}", "") - ascii = strings.ReplaceAll(ascii, "{MAGENTA}", "") - ascii = strings.ReplaceAll(ascii, "{CYAN}", "") + ascii = regex.ReplaceAllString(ascii, "") return ascii }