2025-12-07 02:06:32 +07:00

40 lines
695 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package story_service
import "strings"
var (
replaceMap = map[string]string{
"a": "а",
"e": "е",
"o": "о",
"c": "с",
"p": "р",
"x": "х",
"y": "у",
"k": "к",
"m": "м",
"t": "т",
"h": "н",
"b": "в",
"u": "и",
}
)
func clearMatch(s string) string {
s = strings.TrimPrefix(s, "(")
s = strings.TrimPrefix(s, "[")
s = strings.TrimSuffix(s, ")")
s = strings.TrimSuffix(s, "]")
return clearCode(s)
}
func clearCode(code string) string {
code = strings.ToLower(code)
code = strings.TrimSpace(code)
code = strings.ReplaceAll(code, "-", "")
for latin, cyrillic := range replaceMap {
code = strings.ReplaceAll(code, latin, cyrillic)
}
return code
}