xstring

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDecodeChar = errors.New("error occurred on rune decoding")
)

Functions

func Abbreviate

func Abbreviate(str, abbrevMarker string, offset, maxWidth int) (string, error)

func Bytes

func Bytes(s string) []byte

func CommonPrefix

func CommonPrefix(strings ...string) string

func Contains

func Contains(s string, searchChar string) bool

func ContainsAnySubstrings

func ContainsAnySubstrings(s string, subs []string) bool

ContainsAnySubstrings returns whether s contains any of substring in slice.

func ContainsIgnoreCase

func ContainsIgnoreCase(str, searchStr string) bool

func DefaultIfBlank

func DefaultIfBlank(str, defaultStr string) string

func DefaultIfEmpty

func DefaultIfEmpty(str, defaultStr string) string

DefaultIfEmpty returns default String if str is empty.

func DeleteWhitespace

func DeleteWhitespace(str string) string

func Difference

func Difference(a, b string) string

func EndsWith

func EndsWith(str, suffix string, ignoreCase bool) bool

func EndsWithAny

func EndsWithAny(sequence string, searchStrings ...string) bool

func EndsWithCase

func EndsWithCase(str, suffix string) bool

func EndsWithIgnoreCase

func EndsWithIgnoreCase(str, suffix string) bool

func Equals

func Equals(str1, str2 string) bool

func EqualsAny

func EqualsAny(str1 string, searchStrings ...string) bool

func Index

func Index(s, substr string) int

func IndexAny

func IndexAny(s, chars string) int

func IndexOfDifference

func IndexOfDifference(strings ...string) int

IndexOfDifference 匹配字符传切片中的元素是否存在相同子串

func IndexOfDifferenceWithTwoStr

func IndexOfDifferenceWithTwoStr(a, b string) int

func IsAlpha

func IsAlpha(s string) bool

IsAlpha checks if the string contains only unicode letters.

func IsAlphanumeric

func IsAlphanumeric(s string) bool

IsAlphanumeric checks if the string contains only Unicode letters or digits.

func IsAnyBlank

func IsAnyBlank(strings ...string) bool

IsAnyBlank 判断字符串切片存在为空或长度为0或由空白符(whitespace) 构成的元素

func IsAnyEmpty

func IsAnyEmpty(strings ...string) bool

IsAnyEmpty 是否存在空字符串

func IsBlank

func IsBlank(s string) bool

IsBlank 判断字符串为空或长度为0或由空白符(whitespace) 构成

func IsEmpty

func IsEmpty(s string) bool

IsEmpty 判断字符串是否为空

func IsNoneBlank

func IsNoneBlank(strings ...string) bool

IsNoneBlank 判断字符串切片不存在为空或长度为0或由空白符(whitespace) 构成的元素

func IsNoneEmpty

func IsNoneEmpty(strings ...string) bool

IsNoneEmpty 判断是否不存在空字符串

func IsNotBlank

func IsNotBlank(s string) bool

IsNotBlank 判断字符串不为空或长度为0或由空白符(whitespace) 构成

func IsNotEmpty

func IsNotEmpty(s string) bool

IsNotEmpty 判断字符串是否不为空

func IsNumeric

func IsNumeric(s string) bool

IsNumeric Checks if the string contains only digits. A decimal point is not a digit and returns false.

func IsNumerical

func IsNumerical(s string) bool

IsNumerical 是否数字

func Left

func Left(str string, n int) string

func Len

func Len(str string) int

Len returns str length.

func MustReverse

func MustReverse(s string) string

MustReverse reverses a string, panics when error happens.

func PadCenterChar

func PadCenterChar(s string, size int, ch rune) string

PadCenterChar center pad a string with a specified character in a larger string(specified size). if the size is less than the param string, the param string is returned. NOTE: size is unicode size.

func PadCenterSpace

func PadCenterSpace(s string, size int) string

PadCenterSpace center pad a string with space character(' ') in a larger string(specified size). if the size is less than the param string, the param string is returned. note: size is unicode size.

func PadLeftChar

func PadLeftChar(s string, size int, ch Char) string

PadLeftChar left pad a string with a specified character in a larger string (specified size). if the size is less than the param string, the param string is returned. NOTE: size is unicode size.

func PadLeftSpace

func PadLeftSpace(s string, size int) string

PadLeftSpace left pad a string with space character(' ') in a larger string(specified size). if the size is less than the param string, the param string is returned. NOTE: size is unicode size.

func PadRightChar

func PadRightChar(s string, size int, ch rune) string

PadRightChar right pad a string with a specified character in a larger string(specified size). if the size is less than the param string, the param string is returned. NOTE: size is unicode size.

func PadRightSpace

func PadRightSpace(s string, size int) string

PadRightSpace right pad a string with space character(' ') in a large string(specified size). if the size is less than the param string, the param string is returned. NOTE: size is unicode size.

func RegionMatches

func RegionMatches(str string, ignoreCase bool, thisStart int, substr string, start int, length int) bool

func RemoveChar

func RemoveChar(s string, rmVal Char) string

RemoveChar removes all occurrences of a specified character from the string.

func RemoveString

func RemoveString(s, rmStr string) string

RemoveString removes all occurrences of a substring from the string.

func RepeatChar

func RepeatChar(ch Char, repeat int) string

RepeatChar returns padding using the specified delimiter repeated to a given length.

func Reverse

func Reverse(s string) (string, error)

Reverse reverses a string with error status returned.

func Right(str string, n int) string

Right returns

func Rotate

func Rotate(s string, shift int) string

Rotate rotates(circular shift) a string of shift characters.

func Shuffle

func Shuffle(s string) string

Shuffle shuffles runes in a string and returns.

func Sub

func Sub(s string, start, end int) string

Sub returns substring from specified string avoiding panics with index start and end. start, end are based on unicode(utf8) count.

func SubStart

func SubStart(s string, start int) string

SubStart returns substring from specified string avoiding panics with start. start, end are based on unicode(utf8) count.

func Substring

func Substring(str string, start int, end int) string

func SubstringStart

func SubstringStart(str string, start int) string

func Trim

func Trim(s string, cutSet string) string

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

func TrimAll

func TrimAll(strings []string, stripChars string) []string

func TrimLeft

func TrimLeft(str string, stripStr string) string

func TrimRight

func TrimRight(str string, stripStr string) string

func TrimSpace

func TrimSpace(s string) string

TrimSpace 返回字符串s的一部分,并删除了Unicode定义的所有首尾空格

Types

type Char

type Char = rune

Char is rune Alias.

Jump to

Keyboard shortcuts

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