Sha256: a4c967e6c848e94ac6a48d77a10653e348d713aab17b9623b53245310f7952c6

Contents?: true

Size: 367 Bytes

Versions: 143

Compression:

Stored size: 367 Bytes

Contents

package acronym

import (
	"fmt"
	"regexp"
	"strings"
)

const testVersion = 2

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

143 entries across 143 versions & 1 rubygems

Version Path
trackler-2.0.8.43 tracks/go/exercises/acronym/example.go
trackler-2.0.8.42 tracks/go/exercises/acronym/example.go
trackler-2.0.8.41 tracks/go/exercises/acronym/example.go
trackler-2.0.8.40 tracks/go/exercises/acronym/example.go
trackler-2.0.8.39 tracks/go/exercises/acronym/example.go
trackler-2.0.8.38 tracks/go/exercises/acronym/example.go
trackler-2.0.8.37 tracks/go/exercises/acronym/example.go
trackler-2.0.8.36 tracks/go/exercises/acronym/example.go
trackler-2.0.8.35 tracks/go/exercises/acronym/example.go
trackler-2.0.8.34 tracks/go/exercises/acronym/example.go
trackler-2.0.8.33 tracks/go/exercises/acronym/example.go
trackler-2.0.8.32 tracks/go/exercises/acronym/example.go
trackler-2.0.8.31 tracks/go/exercises/acronym/example.go
trackler-2.0.8.30 tracks/go/exercises/acronym/example.go
trackler-2.0.8.29 tracks/go/exercises/acronym/example.go
trackler-2.0.8.28 tracks/go/exercises/acronym/example.go
trackler-2.0.8.27 tracks/go/exercises/acronym/example.go
trackler-2.0.8.26 tracks/go/exercises/acronym/example.go
trackler-2.0.8.24 tracks/go/exercises/acronym/example.go
trackler-2.0.8.23 tracks/go/exercises/acronym/example.go