str

package
v0.0.42 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package str provides string utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CamelSplit

func CamelSplit(s string) []string

CamelSplit splits a camelcase word and returns a list of words. It also supports digits. Both lower camel case and upper camel case are supported. As per Go naming conventions multiple Upper case letters together are considered an abbreviation and therefore a word.

Examples:

""                    → []
"lowercase"           → ["lowercase"]
"Class"               → ["Class"]
"MyClass"             → ["My", "Class"]
"MyC"                 → ["My", "C"]
"HTML"                → ["HTML"]
"PDFLoader"           → ["PDF", "Loader"]
"AString"             → ["A", "String"]
"SimpleXMLParser"     → ["Simple", "XML", "Parser"]
"vimRPCPlugin"        → ["vim", "RPC", "Plugin"]
"GL11Version"         → ["GL", "11", "Version"]
"99Bottles"           → ["99", "Bottles"]
"May5"                → ["May", "5"]
"BFG9000"             → ["BFG", "9000"]
"BöseÜberraschung"    → ["Böse", "Überraschung"]
"Two  spaces"         → ["Two", "  ", "spaces"]
"BadUTF8\xe2\xe2\xa1" → ["BadUTF8\xe2\xe2\xa1"]

This code is inspired by https://github.com/fatih/camelcase (MIT licensed).

func ToCamelCase added in v0.0.12

func ToCamelCase(s string) string

ToCamelCase converts a string to lower camel case (as used for unexported Go indentifiers), converting the entire first word to lowercase. The word boundaries are located as per CamelSplit. For example, "HelloWorld" becomes "helloWorld", "HTTPDir" becomes "httpDir". If the string contains invalid utf-8, the result is undefined.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL