Documentation ¶
Index ¶
- Variables
- func After(s, char string) string
- func AfterLast(s, char string) string
- func Before(s, char string) string
- func BeforeLast(s, char string) string
- func BytesToString(bytes []byte) string
- func CamelCase(s string) string
- func Capitalize(s string) string
- func ContainsAll(str string, substrs []string) bool
- func ContainsAny(str string, substrs []string) bool
- func HasPrefixAny(str string, prefixes []string) bool
- func HasSuffixAny(str string, suffixes []string) bool
- func HideString(origin string, start, end int, replaceChar string) string
- func IndexOffset(str string, substr string, idxFrom int) int
- func IsBlank(str string) bool
- func IsEmpty(val string) bool
- func IsString(v any) bool
- func KebabCase(s string) string
- func LowerFirst(s string) string
- func Pad(source string, size int, padStr string) string
- func PadEnd(source string, size int, padStr string) string
- func PadStart(source string, size int, padStr string) string
- func RemoveNonPrintable(str string) string
- func RemovePrefix(s string, prefix string) string
- func RemoveSuffix(s string, suffix string) string
- func RemoveWhiteSpace(str string, repalceAll bool) string
- func ReplaceWithMap(str string, replaces map[string]string) string
- func Reverse(s string) string
- func SetPrefix(s string, prefix string) string
- func SetSuffix(s string, suffix string) string
- func SnakeCase(s string) string
- func SplitAndTrim(str, delimiter string, characterMask ...string) []string
- func SplitEx(s, sep string, removeEmptyString bool) []string
- func SplitWords(s string) []string
- func StringToBytes(str string) (b []byte)
- func Substring(s string, offset int, length uint) string
- func Trim(str string, characterMask ...string) string
- func Unwrap(str string, wrapToken string) string
- func UpperFirst(s string) string
- func UpperKebabCase(s string) string
- func UpperSnakeCase(s string) string
- func Utf8StringLength(str string) int
- func Utf8TruncateText(text string, max int, omission string) string
- func WordCount(s string) int
- func Wrap(str string, wrapWith string) string
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultTrimChars are the characters which are stripped by Trim* functions in default. DefaultTrimChars = string([]byte{ '\t', '\v', '\n', '\r', '\f', ' ', 0x00, 0x85, 0xA0, }) )
Functions ¶
func After ¶
After returns the substring after the first occurrence of a specified string in the source string.
func AfterLast ¶
AfterLast returns the substring after the last occurrence of a specified string in the source string.
func Before ¶
Before returns the substring of the source string up to the first occurrence of the specified string.
func BeforeLast ¶
BeforeLast returns the substring of the source string up to the last occurrence of the specified string.
func BytesToString ¶
BytesToString converts a byte slice to string without a memory allocation.
func CamelCase ¶
CamelCase coverts string to camelCase string. Non letters and numbers will be ignored.
func Capitalize ¶
Capitalize converts the first character of a string to upper case and the remaining to lower case.
func ContainsAll ¶
ContainsAll return true if target string contains all the substrs.
func ContainsAny ¶
ContainsAny return true if target string contains any one of the substrs.
func HasPrefixAny ¶
HasPrefixAny check if a string starts with any of a slice of specified strings.
func HasSuffixAny ¶
HasSuffixAny check if a string ends with any of a slice of specified strings.
func HideString ¶
HideString hide some chars in source string with param `replaceChar`. replace range is origin[start : end]. [start, end)
func IndexOffset ¶
IndexOffset returns the index of the first instance of substr in string after offsetting the string by `idxFrom`, or -1 if substr is not present in string.
func LowerFirst ¶
LowerFirst converts the first character of string to lower case.
func Pad ¶
Pad pads string on the left and right side if it's shorter than size. Padding characters are truncated if they exceed size.
func PadEnd ¶
PadEnd pads string on the right side if it's shorter than size. Padding characters are truncated if they exceed size.
func PadStart ¶
PadStart pads string on the left side if it's shorter than size. Padding characters are truncated if they exceed size.
func RemoveNonPrintable ¶
RemoveNonPrintable remove non-printable characters from a string.
func RemovePrefix ¶
func RemoveSuffix ¶
func RemoveWhiteSpace ¶
RemoveWhiteSpace remove whitespace characters from a string. when set repalceAll is true removes all whitespace, false only replaces consecutive whitespace characters with one space.
func ReplaceWithMap ¶
ReplaceWithMap returns a copy of `str`, which is replaced by a map in unordered way, case-sensitively.
func SplitAndTrim ¶
SplitAndTrim splits string `str` by a string `delimiter` to a slice, and calls Trim to every element of this slice. It ignores the elements which are empty after Trim.
func SplitEx ¶
SplitEx split a given string which can control the result slice contains empty string or not.
func SplitWords ¶
SplitWords splits a string into words, word only contains alphabetic characters.
func StringToBytes ¶
StringToBytes converts a string to byte slice without a memory allocation.
func Substring ¶
Substring returns a substring of the specified length starting at the specified offset position.
func Trim ¶
Trim strips whitespace (or other characters) from the beginning and end of a string. The optional parameter `characterMask` specifies the additional stripped characters.
func UpperFirst ¶
UpperFirst converts the first character of string to upper case.
func UpperKebabCase ¶
UpperKebabCase coverts string to upper KEBAB-CASE, non letters and numbers will be ignored
func UpperSnakeCase ¶
UpperSnakeCase coverts string to upper SNAKE_CASE, non letters and numbers will be ignored
func Utf8StringLength ¶
Types ¶
This section is empty.