github.com/containers/podman/v2@v2.2.2-0.20210501105131-c1e07d070c4c/pkg/util/camelcase/README.md (about) 1 # CamelCase [![GoDoc](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](http://godoc.org/github.com/fatih/camelcase) [![Build Status](http://img.shields.io/travis/fatih/camelcase.svg?style=flat-square)](https://travis-ci.org/fatih/camelcase) 2 3 CamelCase is a Golang (Go) package to split the words of a camelcase type 4 string into a slice of words. It can be used to convert a camelcase word (lower 5 or upper case) into any type of word. 6 7 ## Splitting rules: 8 9 1. If string is not valid UTF-8, return it without splitting as 10 single item array. 11 2. Assign all unicode characters into one of 4 sets: lower case 12 letters, upper case letters, numbers, and all other characters. 13 3. Iterate through characters of string, introducing splits 14 between adjacent characters that belong to different sets. 15 4. Iterate through array of split strings, and if a given string 16 is upper case: 17 * if subsequent string is lower case: 18 * move last character of upper case string to beginning of 19 lower case string 20 21 ## Install 22 23 ```bash 24 go get github.com/fatih/camelcase 25 ``` 26 27 ## Usage and examples 28 29 ```go 30 splitted := camelcase.Split("GolangPackage") 31 32 fmt.Println(splitted[0], splitted[1]) // prints: "Golang", "Package" 33 ``` 34 35 Both lower camel case and upper camel case are supported. For more info please 36 check: [http://en.wikipedia.org/wiki/CamelCase](http://en.wikipedia.org/wiki/CamelCase) 37 38 Below are some example cases: 39 40 ``` 41 "" => [] 42 "lowercase" => ["lowercase"] 43 "Class" => ["Class"] 44 "MyClass" => ["My", "Class"] 45 "MyC" => ["My", "C"] 46 "HTML" => ["HTML"] 47 "PDFLoader" => ["PDF", "Loader"] 48 "AString" => ["A", "String"] 49 "SimpleXMLParser" => ["Simple", "XML", "Parser"] 50 "vimRPCPlugin" => ["vim", "RPC", "Plugin"] 51 "GL11Version" => ["GL", "11", "Version"] 52 "99Bottles" => ["99", "Bottles"] 53 "May5" => ["May", "5"] 54 "BFG9000" => ["BFG", "9000"] 55 "BöseÜberraschung" => ["Böse", "Überraschung"] 56 "Two spaces" => ["Two", " ", "spaces"] 57 "BadUTF8\xe2\xe2\xa1" => ["BadUTF8\xe2\xe2\xa1"] 58 ```