package util import ( "strings" ) // RemoveNPCAttribution removes NPC attribution. func RemoveNPCAttribution(str string) string { lastOpen := strings.LastIndex(str, "(") lastClose := strings.LastIndex(str, ")") ending := len(str) - 1 if lastOpen > 0 && str[lastOpen-1] != '(' && (lastClose == -1 || lastClose == ending) { cutoff := lastOpen for cutoff > 1 && str[cutoff-1] == ' ' { cutoff-- } return str[:cutoff] } return str }