Documentation
¶
Overview ¶
Package token contains a Token data structure representing a string in slices of runes in varous casings.
Index ¶
- Variables
- type Caser
- type Token
- func (t Token) Clone() Token
- func (t Token) FirstLowerRune() (rune, bool)
- func (t Token) FirstRune() (rune, bool)
- func (t Token) FirstUpperRune() (rune, bool)
- func (t Token) HasLower() bool
- func (t Token) IsEmpty() bool
- func (t Token) IsNumber(additionalRules ...map[rune]func(index int, r rune, val []rune) bool) bool
- func (t Token) Len() int
- func (t Token) Lower() string
- func (t Token) LowerFirst() string
- func (t Token) LowerReversedRunes() []rune
- func (t Token) LowerRunes() []rune
- func (t Token) Reverse() Token
- func (t Token) ReverseSplit() []Token
- func (t Token) Runes() []rune
- func (t Token) Split() []Token
- func (t Token) String() string
- func (t Token) Upper() string
- func (t Token) UpperFirst() string
- func (t Token) UpperFirstLowerRest() string
- func (t Token) UpperRunes() []rune
- func (t Token) Value() string
- type Unicode
Constants ¶
This section is empty.
Variables ¶
var ( TurkishCaser = &unicode.TurkishCase AzeriCaser = &unicode.AzeriCase )
var DefaultCaser = Unicode{}
Functions ¶
This section is empty.
Types ¶
type Caser ¶ added in v0.3.0
type Caser interface {
// ToLower maps the rune to lower case
ToLower(r rune) rune
// ToUpper maps the rune to upper case
ToUpper(r rune) rune
// ToTitle maps the rune to title case
ToTitle(r rune) rune
}
Caser is satisfied by types which can map runes to their lowercase and uppercase equivalents.
func CaserOrDefault ¶ added in v0.3.0
type Token ¶
type Token struct {
// contains filtered or unexported fields
}
Token contains a slice of runes representing the raw value and value in lowercase form.
This is used for the
func AppendRune ¶
AppendRune append the rune to the current token.
func FromString ¶
func (Token) FirstLowerRune ¶ added in v0.3.0
func (Token) FirstUpperRune ¶ added in v0.3.0
func (Token) HasLower ¶ added in v0.3.0
HasLower returns true if any rune in the token is a unicode lowercase letter.
func (Token) IsNumber ¶
IsNumber reports true if the Token is considered a valid number based on the following rules:
- If the Token is composed only of numbers
- If the Token is prefixed with any of the following: + - . v V # and followed by a number
- Numbers may only be separated by a single '.' and '.' may be the first rune or proceeded by a number, '+', or '-'
- A single 'e' or 'E' may only be used in the exponent portion of a number
- 'e' or 'E' may be followed
- ',' must be preceded by a number and followed by a number
- if additionalRules is not nil and the rune is present in the map, the result of the provided func overrides the rules above
func (Token) LowerFirst ¶
func (Token) LowerReversedRunes ¶ added in v0.3.0
func (Token) LowerRunes ¶ added in v0.3.0
func (Token) ReverseSplit ¶ added in v0.3.0
func (Token) Split ¶
Split returns the current token split into a slice of Tokens for each rune in the list.