Sha256: c956375b471aaba13ff3ef17b7bddc73c06f9ffa81d712592a8928ca4fb77aca
Contents?: true
Size: 367 Bytes
Versions: 39
Compression:
Stored size: 367 Bytes
Contents
package acronym import ( "fmt" "regexp" "strings" ) const testVersion = 1 func abbreviate(s string) string { regex := regexp.MustCompile("[A-Z]+[a-z]*|[a-z]+") words := regex.FindAllString(s, -1) abbr := []string{} for _, word := range words { abbr = append(abbr, string(word[0])) } return fmt.Sprintf("%s", strings.ToUpper(strings.Join(abbr, ""))) }
Version data entries
39 entries across 39 versions & 1 rubygems