stringx

package
v1.2.12 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidStartPosition is an error that indicates the start position is invalid.
	ErrInvalidStartPosition = errors.New("start position is invalid")
	// ErrInvalidStopPosition is an error that indicates the stop position is invalid.
	ErrInvalidStopPosition = errors.New("stop position is invalid")
)

Functions

func CamelCase

func CamelCase(s string) string

CamelCase to transform string to CamelCase

func Contains

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

Contains checks if str is in list.

func ContainsIgnoreCase added in v1.0.17

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

ContainsIgnoreCase checks if str is in list (ignore case).

func Filter

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

Filter filters chars from s with given filter function.

func HasEmpty

func HasEmpty(args ...string) bool

HasEmpty checks if there are empty strings in args.

func LowerCamelCase

func LowerCamelCase(s string) string

LowerCamelCase to transform string to LowerCamelCase

func MustJsonString added in v1.0.22

func MustJsonString(obj interface{}) string

MustJsonString returns string from json.Marshal.

func NewSimpleHashId

func NewSimpleHashId(salt string, minLength int, alphabet ...string) *simpleHashId

func NotEmpty

func NotEmpty(args ...string) bool

NotEmpty checks if all strings are not empty in args.

func Remove

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

Remove removes given strs from strings.

func Reverse

func Reverse(s string) string

Reverse reverses s.

func Substr

func Substr(str string, start, 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

TakeOne returns valid string if not empty or later one.

Types

type Trie added in v1.0.15

type Trie interface {
	// Filter filter sentence get masked sentence and get keywords
	Filter(text string) (string, []string)
	// FindKeywords get sentence keywords
	FindKeywords(text string) []string
	// AddWord add keywords
	// Attention: NOT thread safe
	AddWords(text ...string)
}

Trie interface

func NewTrie added in v1.0.15

func NewTrie(words ...string) Trie

NewTrie new trie

Jump to

Keyboard shortcuts

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