token

package
v0.7.10 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package token contains a funcs for working with a string as a token.

Index

Constants

This section is empty.

Variables

View Source
var (
	TurkishCaser = &unicode.TurkishCase
	AzeriCaser   = &unicode.AzeriCase
)
View Source
var DefaultCaser = Unicode{}

Functions

func Append

func Append(caser Caser, t string, elems ...string) string

Append appends all of elems to t

func AppendRune

func AppendRune(caser Caser, t string, runes ...rune) string

AppendRune append the rune to the current token.

func FirstRune added in v0.7.0

func FirstRune(s string) (rune, bool)

func HasLower added in v0.7.0

func HasLower(s string) bool

HasLower returns true if any rune in the token is a unicode lowercase letter.

func IsEmpty added in v0.7.0

func IsEmpty(s string) bool

func IsNumber added in v0.7.0

func IsNumber(s string, additionalRules NumberRules) bool

IsNumber reports true if the string 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 LowerFirst added in v0.7.0

func LowerFirst(caser Caser, s string) string

func Reverse added in v0.7.0

func Reverse(caser Caser, s string) string

func ToLower added in v0.7.0

func ToLower(caser Caser, s string) string

func ToUpper added in v0.7.0

func ToUpper(caser Caser, s string) string

func UpperFirst added in v0.7.0

func UpperFirst(caser Caser, s string) string

func UpperFirstLowerRest added in v0.7.0

func UpperFirstLowerRest(caser Caser, s string) string

func Write added in v0.7.5

func Write(b *strings.Builder, caser Caser, e string)

Write writes e to b

func WriteLower added in v0.7.5

func WriteLower(b *strings.Builder, caser Caser, s string)

func WriteRune added in v0.7.5

func WriteRune(b *strings.Builder, caser Caser, r rune)

WriteRune writes the runes to the b.

func WriteSplitLower added in v0.7.5

func WriteSplitLower(b *strings.Builder, caser Caser, sep string, elems ...string)

func WriteSplitLowerFirstUpperRest added in v0.7.5

func WriteSplitLowerFirstUpperRest(b *strings.Builder, caser Caser, sep string, s string)

func WriteSplitUpper added in v0.7.5

func WriteSplitUpper(b *strings.Builder, caser Caser, sep string, elems ...string)

func WriteUpper added in v0.7.5

func WriteUpper(b *strings.Builder, caser Caser, s string)

func WriteUpperFirstLowerRest added in v0.7.5

func WriteUpperFirstLowerRest(b *strings.Builder, caser Caser, s string)

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

func CaserOrDefault(caser Caser) Caser

type NumberRules added in v0.7.0

type NumberRules map[rune]func(index int, r rune, val string) bool

type Unicode added in v0.3.0

type Unicode struct{}

func (Unicode) ToLower added in v0.3.0

func (Unicode) ToLower(r rune) rune

ToUpper maps the rune to lower case using unicode.ToLower

func (Unicode) ToTitle added in v0.3.0

func (Unicode) ToTitle(r rune) rune

ToTitle maps the rune to title case using unicode.ToTitle.

func (Unicode) ToUpper added in v0.3.0

func (Unicode) ToUpper(r rune) rune

ToUpper maps the rune to upper case using unicode.ToUpper

Jump to

Keyboard shortcuts

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