gstring

package
v0.0.0-...-04ff805 Latest Latest
Warning

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

Go to latest
Published: May 22, 2022 License: MIT Imports: 8 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrayEqual

func ArrayEqual(a, b []string, orderSensitive bool) bool

func Contains

func Contains(elements []string, toFind string) bool

func ContainsNotCaseSensitive

func ContainsNotCaseSensitive(elements []string, toFind string) bool

func CountByValue

func CountByValue(elements []string, toFind string) int

func CountDigit

func CountDigit(s string) int

Get count of digit character in string

func EndWith

func EndWith(s, toFind string) bool

func Equal

func Equal(s1, s2 []string) bool

func EqualLower

func EqualLower(s1, s2 string) bool

func EqualUpper

func EqualUpper(s1, s2 string) bool

func FindMaxLength

func FindMaxLength(elements []string) []string

func GetFirstLines

func GetFirstLines(src string, count int) string

func GetLastLines

func GetLastLines(src string, count int) string

func GetLovelySmile

func GetLovelySmile() string

func HeadToLowerASCII

func HeadToLowerASCII(s string, n int) string

func IndexAfter

func IndexAfter(s string, substr string, fromIndex int) int

Find index of sep string in src string, and start searching from given index - fromIndex Sample: IndexAfter("01234567893", "3", 5) = 10

func IndexAfterUTF8

func IndexAfterUTF8(s string, substr string, fromIndex int) int

func IndexAscii

func IndexAscii(s, substr string) int

以Byte为单元的Index函数

func IndexInArray

func IndexInArray(ss []string, tofind string) int

func IndexUTF8

func IndexUTF8(s, substr string) int

以UTF8为单元的Index函数

func IsASCII

func IsASCII(s string) bool

func IsHexString

func IsHexString(s string) bool

Is every letter is hex letter [0-9] [a-f]

func IsMd5String

func IsMd5String(s string) bool

func LastIndexUTF8

func LastIndexUTF8(s, substr string) int

func LastSubstrByLenAscii

func LastSubstrByLenAscii(s string, length int) string

func LastSubstrByLenUTF8

func LastSubstrByLenUTF8(s string, length int) string

func LenAscii

func LenAscii(s string) int

以Byte为单元的Len函数

func LenUTF8

func LenUTF8(s string) int

以UTF8为单元的Len函数

func Merge

func Merge(elements1, elements2 []string) []string

func OnlyFirstLetterUpperCase

func OnlyFirstLetterUpperCase(s string) string

func Prepend

func Prepend(slice []string, elems ...string) []string

插入到前面

func RemoveByValue

func RemoveByValue(elements []string, toRemove string) []string

func RemoveByValues

func RemoveByValues(elements, toRemove []string) []string

func RemoveDuplicate

func RemoveDuplicate(elements []string) []string

func RemoveEmpty

func RemoveEmpty(elements []string) []string

Delete empty elements - "".

func RemoveEntirelySpaces

func RemoveEntirelySpaces(elements []string) []string

Delete elements composed entirely of spaces, like " ".

func RemoveFirstLines

func RemoveFirstLines(src string, count int) string

func RemoveHead

func RemoveHead(s string, length int) string

func RemoveIndex

func RemoveIndex(s string, index int) string

func RemoveLastLines

func RemoveLastLines(src string, count int) string

func RemoveNull

func RemoveNull(elements []string) []string

Delete empty elements - "".

func RemoveStartWith

func RemoveStartWith(elements []string, toFind string) []string

Delete elements start with 'toFind'.

func RemoveTail

func RemoveTail(s string, length int) string

func ReplaceReverse

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

func ReplaceWithTags

func ReplaceWithTags(s string, begin string, endAfterBegin string, replaceStr string, replaceTime int) (string, error)

func Reverse

func Reverse(s string) string

func Shuffle

func Shuffle(elements []string) []string

Random sort

func SortByHex

func SortByHex(s string) string

sort string by rune hex value example: 722abBCcA -> 277ABCabc

func SplitByLen

func SplitByLen(s string, length int) []string

func SplitChunksAscii

func SplitChunksAscii(s string, chunkSize int, fromLeft bool) []string

SplitChunks("1234567", 3, false) == "1 234 567"

func SplitRunes

func SplitRunes(s string) []rune

func SplitToLines

func SplitToLines(s string) []string

func StartWith

func StartWith(s, toFind string) bool

func StartWithRune

func StartWithRune(s, sub []rune) bool

[]rune的StartWith函数

func SubstrAscii

func SubstrAscii(s string, begin, end int) (string, error)

以字节为单元的Substr函数 如果包含中文等UTF8字符,则不可以使用此函数

func SubstrBetween

func SubstrBetween(s string, begin string, end string,
	searchBeginFromLeft bool, searchEndFromLeft bool,
	includBegin bool, includEnd bool) (string, error)

Get substring of source string sample: SubstrAscii("ab)cd(efgh)ij)kl", "(", ")", true, true, true, true) == "efgh"

func SubstrBetweenUTF8

func SubstrBetweenUTF8(s string, begin string, end string,
	searchBeginFromLeft bool, searchEndFromLeft bool,
	includBegin bool, includEnd bool) (string, error)

func SubstrByLenAscii

func SubstrByLenAscii(s string, length int) string

取前面一段字符串,最大长度为length

func SubstrByLenUTF8

func SubstrByLenUTF8(s string, length int) string

func ToLower

func ToLower(elements []string) []string

func ToUpper

func ToUpper(elements []string) []string

func TrimLeftAll

func TrimLeftAll(s, cutset string) string

trim s until s doesn't start with cutset

func TrimRightAll

func TrimRightAll(s, cutset string) string

trim s until s doesn't end with cutset

func TrimUnASCII

func TrimUnASCII(s string) string

func TrySubstrLenAscii

func TrySubstrLenAscii(s string, begin, length int) string

以字节为单元的Substr函数 如果begine、length过大过小,都不会报错

func TrySubstrLenUTF8

func TrySubstrLenUTF8(s string, begin, length int) string

以UTF8为单元的Substr函数

Types

type Checker

type Checker struct {
	// contains filtered or unexported fields
}

func NewChecker

func NewChecker() *Checker

func (*Checker) Allow

func (r *Checker) Allow(min, max rune) *Checker

func (*Checker) AllowRune

func (r *Checker) AllowRune(a rune) *Checker

func (*Checker) Check

func (r *Checker) Check(s string) error

func (*Checker) String

func (r *Checker) String() string

Jump to

Keyboard shortcuts

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