stringx

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidStartPosition = errors.New("start position is invalid")
	ErrInvalidStopPosition  = errors.New("stop position is invalid")
)

Functions

func Contains

func Contains(list []string, str string) bool

func DecodeChineseToFloat64

func DecodeChineseToFloat64(cn string) (float64, error)

DecodeToFloat64 : decode a chinese number string into Float64

func DecodeChineseToInt64

func DecodeChineseToInt64(chinese string) (int64, error)

DecodeToInt64 : decode a chinese number string into Int64

func EncodeChineseFromFloat64

func EncodeChineseFromFloat64(num float64) string

EncodeFromFloat64 : convert float64 into Chinese number 由于float64固然存在的精度问题,本函数可能不会特别精准。所以小数部分最多精确到6位。

func EncodeChineseFromInt64

func EncodeChineseFromInt64(num int64) string

EncodeFromInt64 : convert int64 into Chinese number

func Filter

func Filter(s string, filter func(r rune) bool) string

func HasEmpty

func HasEmpty(args ...string) bool

func MustDecodeChineseToFloat64

func MustDecodeChineseToFloat64(cn string) float64

MustDecodeToFloat64 : decode a chinese number string into Float64 without error

func MustDecodeChineseToInt64

func MustDecodeChineseToInt64(chinese string) int64

MustDecodeToInt64 : decode a chinese number string into Int64 without error

func NotEmpty

func NotEmpty(args ...string) bool

func Remove

func Remove(strings []string, strs ...string) []string

func Reverse

func Reverse(s string) string

func Substr

func Substr(str string, start int, stop int) (string, error)

Substr returns runes between start and stop [start, stop) regardless of the chars are ascii or utf8

func TakeOne

func TakeOne(valid, or string) string

func TakeWithPriority

func TakeWithPriority(fns ...func() string) string

func Union

func Union(first, second []string) []string

Types

type Replacer

type Replacer interface {
	Replace(text string) string
}

func NewReplacer

func NewReplacer(mapping map[string]string) Replacer

type Trie

type Trie interface {
	Filter(text string) (string, []string, bool)
	FindKeywords(text string) []string
}

func NewTrie

func NewTrie(words []string, opts ...TrieOption) Trie

type TrieOption

type TrieOption func(trie *trieNode)

func WithMask

func WithMask(mask rune) TrieOption

Jump to

Keyboard shortcuts

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