camel

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2022 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package camel implements camel case word splitting.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Split

func Split(str string) []string

Split returns a slice of strings split according to camel case rules. The string is split so that words start with a leading capital unless it is the first word in the string, which may start with a lower case. The underscore character breaks words and numbers are separated from words. Invalid UTF-8 encoded strings are not split.

Types

type Splitter

type Splitter struct {
	// contains filtered or unexported fields
}

Splitter implements camel case word splitting with additional control over word boundaries where case-sensitive known words can be provided. The zero value of Splitter can be used and Splitter{}.Split is the equivalent of Split.

func NewSplitter

func NewSplitter(known []string) Splitter

NewSplitter returns a new camel case splitter using the provided known words. The words should be provided in order of checking priority.

func (Splitter) Split

func (s Splitter) Split(str string) []string

Split returns a slice of strings split according to camel case rules after having first split the string according the provided list of known words in the order they were provided to NewSplitter. When known words overlap in the string, only the first matching word is used.

Jump to

Keyboard shortcuts

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