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.2 tracks/go/exercises/acronym/example.go
trackler-2.0.8.1 tracks/go/exercises/acronym/example.go
trackler-2.0.7.0 tracks/go/exercises/acronym/example.go
trackler-2.0.6.44 tracks/go/exercises/acronym/example.go
trackler-2.0.6.43 tracks/go/exercises/acronym/example.go
trackler-2.0.6.42 tracks/go/exercises/acronym/example.go
trackler-2.0.6.41 tracks/go/exercises/acronym/example.go
trackler-2.0.6.40 tracks/go/exercises/acronym/example.go
trackler-2.0.6.39 tracks/go/exercises/acronym/example.go
trackler-2.0.6.38 tracks/go/exercises/acronym/example.go
trackler-2.0.6.37 tracks/go/exercises/acronym/example.go
trackler-2.0.6.36 tracks/go/exercises/acronym/example.go
trackler-2.0.6.35 tracks/go/exercises/acronym/example.go
trackler-2.0.6.34 tracks/go/exercises/acronym/example.go
trackler-2.0.6.33 tracks/go/exercises/acronym/example.go
trackler-2.0.6.32 tracks/go/exercises/acronym/example.go
trackler-2.0.6.31 tracks/go/exercises/acronym/example.go
trackler-2.0.6.30 tracks/go/exercises/acronym/example.go
trackler-2.0.6.29 tracks/go/exercises/acronym/example.go
trackler-2.0.6.28 tracks/go/exercises/acronym/example.go