Browse Source

CommonRunesInStringArray added

master
Klaus Wendel 1 year ago
parent
commit
8aac271e42
  1. 38
      ebkTools.go

38
ebkTools.go

@ -237,3 +237,41 @@ func ByteCountBinary(b int64) string {
}
return fmt.Sprintf("%.1f %ciB", float64(b)/float64(div), "KMGTPE"[exp])
}
/*
const (
a = "archium"
b = "archidum"
c = "archivum"
)
func main() {
s := make([]string, 3, 3)
s = []string{a, b, c}
fmt.Println(CommonRunesInStringArray(s))
}
//results in "archi"
*/
func CommonRunesInStringArray(sa []string) string {
var tmpRunes []rune
for i, v := range sa[0] {
good := false
for _, w := range sa {
if v == rune(w[i]) {
good = true
} else {
good = false
}
}
if good {
tmpRunes = append(tmpRunes, v)
//fmt.Println(i, string(v))
}
}
return string(tmpRunes)
}

Loading…
Cancel
Save