stringx

package
v0.0.0-...-c33cebc Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: AGPL-3.0 Imports: 7 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllControl

func AllControl(s string) bool

func AllDigit

func AllDigit(s string) bool

func AllGraphic

func AllGraphic(s string) bool

func AllLetter

func AllLetter(s string) bool

func AllLetterOrDigit

func AllLetterOrDigit(s string) bool

func AllLower

func AllLower(s string) bool

func AllMark

func AllMark(s string) bool

func AllPrint

func AllPrint(s string) bool

func AllPunct

func AllPunct(s string) bool

func AllSpace

func AllSpace(s string) bool

func AllSymbol

func AllSymbol(s string) bool

func AllTitle

func AllTitle(s string) bool

func AllUpper

func AllUpper(s string) bool

func Camel2Snake

func Camel2Snake(s string) string

Camel2Snake 驼峰转蛇形 - 内存优化版本

func ContainsAny

func ContainsAny(s, chars string) bool

ContainsAny reports whether any of the UTF-8-encoded code points in chars are within s.

func ContainsRune

func ContainsRune(s string, r rune) bool

ContainsRune reports whether the Unicode code point r is within s.

func Count

func Count(s, substr string) int

Count counts the number of non-overlapping instances of substr in s.

func EqualFold

func EqualFold(s, t string) bool

EqualFold reports whether s and t are equal under Unicode case-folding.

func Fields

func Fields(s string) []string

Fields splits the string s around each instance of one or more consecutive white space characters.

func FieldsFunc

func FieldsFunc(s string, f func(rune) bool) []string

FieldsFunc splits the string s at each run of Unicode code points c satisfying f(c).

func HasControl

func HasControl(s string) bool

func HasDigit

func HasDigit(s string) bool

func HasGraphic

func HasGraphic(s string) bool

func HasLetter

func HasLetter(s string) bool

func HasLetterOrDigit

func HasLetterOrDigit(s string) bool

func HasLower

func HasLower(s string) bool

func HasMark

func HasMark(s string) bool

func HasPrefix

func HasPrefix(s, prefix string) bool

HasPrefix tests whether the string s begins with prefix.

func HasPrint

func HasPrint(s string) bool

func HasPunct

func HasPunct(s string) bool

func HasSpace

func HasSpace(s string) bool

func HasSuffix

func HasSuffix(s, suffix string) bool

HasSuffix tests whether the string s ends with suffix.

func HasSymbol

func HasSymbol(s string) bool

func HasTitle

func HasTitle(s string) bool

func HasUpper

func HasUpper(s string) bool

func Index

func Index(s, substr string) int

Index returns the index of the first instance of substr in s, or -1 if substr is not present in s.

func IndexAny

func IndexAny(s, chars string) int

IndexAny returns the index of the first instance of any Unicode code point from chars in s, or -1 if no Unicode code point from chars is present in s.

func IsDigit

func IsDigit[M string | []rune](r M) bool

func IsUpper

func IsUpper[M string | []rune](r M) bool

func LastIndex

func LastIndex(s, substr string) int

LastIndex returns the index of the last instance of substr in s, or -1 if substr is not present in s.

func LastIndexAny

func LastIndexAny(s, chars string) int

LastIndexAny returns the index of the last instance of any Unicode code point from chars in s, or -1 if no Unicode code point from chars is present in s.

func Quote

func Quote(s string) string

func QuotePure

func QuotePure(s string) string

func RandLetterNumbers

func RandLetterNumbers(n int) string

func RandLetters

func RandLetters(n int) string

func RandLowerLetterNumbers

func RandLowerLetterNumbers(n int) string

func RandLowerLetters

func RandLowerLetters(n int) string

func RandNumbers

func RandNumbers(n int) string

func RandStringWithSeed

func RandStringWithSeed(n int, seed []rune) string

func RandUpperLetterNumbers

func RandUpperLetterNumbers(n int) string

func RandUpperLetters

func RandUpperLetters(n int) string

func Repeat

func Repeat(s string, count int) string

Repeat returns a new string consisting of count copies of the string s.

func Replace

func Replace(s, old, new string, n int) string

Replace returns a copy of the string s with the first n non-overlapping instances of old replaced by new.

func ReplaceAll

func ReplaceAll(s, old, new string) string

ReplaceAll returns a copy of the string s with all non-overlapping instances of old replaced by new.

func Reverse

func Reverse(s string) string

func Shorten

func Shorten(s string, max int) string

Shorten 缩短字符串

func ShortenShow

func ShortenShow(s string, max int) string

func Snake2Camel

func Snake2Camel(s string) string

Snake2Camel 蛇形转驼峰

func Snake2SmallCamel

func Snake2SmallCamel(s string) string

Snake2SmallCamel 蛇形转小驼峰

func Split

func Split(s, sep string) []string

Split slices s into all substrings separated by sep and returns a slice of the substrings between those separators.

func SplitAfter

func SplitAfter(s, sep string) []string

SplitAfter slices s into all substrings after each instance of sep and returns a slice of those substrings.

func SplitAfterN

func SplitAfterN(s, sep string, n int) []string

SplitAfterN slices s into substrings after each instance of sep and returns a slice of those substrings.

func SplitLen

func SplitLen(s string, max int) []string

SplitLen 按长度分割字符串 - 零拷贝优化版本

func SplitN

func SplitN(s, sep string, n int) []string

SplitN slices s into substrings separated by sep and returns a slice of the substrings between those separators.

func Title

func Title(s string) string

Title returns a copy of the string s with all Unicode letters that begin words mapped to their Unicode title case.

func ToBytes

func ToBytes(s string) []byte

func ToCamel

func ToCamel(s string) string

ToCamel 转驼峰

func ToDot

func ToDot(s string) string

func ToKebab

func ToKebab(s string) string

ToKebab - 基于优化ToSnake的变体

func ToLower

func ToLower(s string) string

ToLower returns s with all Unicode letters mapped to their lower case.

func ToSlash

func ToSlash(s string) string

func ToSmallCamel

func ToSmallCamel(s string) string

ToSmallCamel 转小驼峰

func ToSnake

func ToSnake(s string) string

ToSnake 蛇形 - 零分配优化版本

func ToString

func ToString(b []byte) string

func ToTitle

func ToTitle(s string) string

ToTitle returns a copy of the string s with all Unicode letters mapped to their Unicode title case.

func ToUpper

func ToUpper(s string) string

ToUpper returns s with all Unicode letters mapped to their upper case.

func Trim

func Trim(s, cutset string) string

Trim returns a slice of the string s with all leading and trailing Unicode code points contained in cutset removed.

func TrimLeft

func TrimLeft(s, cutset string) string

TrimLeft returns a slice of the string s with all leading Unicode code points contained in cutset removed.

func TrimPrefix

func TrimPrefix(s, prefix string) string

TrimPrefix returns s without the provided leading prefix string.

func TrimRight

func TrimRight(s, cutset string) string

TrimRight returns a slice of the string s with all trailing Unicode code points contained in cutset removed.

func TrimSpace

func TrimSpace(s string) string

TrimSpace returns a slice of the string s, with all leading and trailing white space removed.

func TrimSuffix

func TrimSuffix(s, suffix string) string

TrimSuffix returns s without the provided trailing suffix string.

func Utf16Len

func Utf16Len[M string | []rune | []byte](str M) int

Types

This section is empty.

Jump to

Keyboard shortcuts

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