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.1.0.27 tracks/go/exercises/acronym/example.go
trackler-2.1.0.26 tracks/go/exercises/acronym/example.go
trackler-2.1.0.25 tracks/go/exercises/acronym/example.go
trackler-2.1.0.24 tracks/go/exercises/acronym/example.go
trackler-2.1.0.23 tracks/go/exercises/acronym/example.go
trackler-2.1.0.22 tracks/go/exercises/acronym/example.go
trackler-2.1.0.21 tracks/go/exercises/acronym/example.go
trackler-2.1.0.20 tracks/go/exercises/acronym/example.go
trackler-2.1.0.19 tracks/go/exercises/acronym/example.go
trackler-2.1.0.18 tracks/go/exercises/acronym/example.go
trackler-2.1.0.17 tracks/go/exercises/acronym/example.go
trackler-2.1.0.16 tracks/go/exercises/acronym/example.go
trackler-2.1.0.15 tracks/go/exercises/acronym/example.go
trackler-2.1.0.14 tracks/go/exercises/acronym/example.go
trackler-2.1.0.13 tracks/go/exercises/acronym/example.go
trackler-2.1.0.12 tracks/go/exercises/acronym/example.go
trackler-2.1.0.11 tracks/go/exercises/acronym/example.go
trackler-2.1.0.10 tracks/go/exercises/acronym/example.go
trackler-2.1.0.9 tracks/go/exercises/acronym/example.go
trackler-2.1.0.8 tracks/go/exercises/acronym/example.go