Documentation ¶
Overview ¶
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-11-01 22:06:35 * @FilePath: \go-toolbox\pkg\stringx\base.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-11-01 02:15:52 * @FilePath: \go-toolbox\pkg\stringx\contains.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-08-03 23:11:56 * @FilePath: \go-toolbox\pkg\stringx\format.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-08-03 16:55:01 * @FilePath: \go-toolbox\pkg\stringx\index.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-08-03 11:02:37 * @FilePath: \go-toolbox\pkg\stringx\remove.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-07-30 17:26:07 * @FilePath: \go-toolbox\pkg\stringx\repeat.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-10-16 19:49:20 * @FilePath: \go-toolbox\pkg\stringx\replace.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-07-30 17:26:07 * @FilePath: \go-toolbox\pkg\stringx\split.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-07-30 17:26:07 * @FilePath: \go-toolbox\pkg\stringx\start_end_with.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-08-03 10:15:25 * @FilePath: \go-toolbox\pkg\stringx\sub.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-07-30 17:26:07 * @FilePath: \go-toolbox\pkg\stringx\trim.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
Index ¶
- func AddPrefixIfNot(str string, prefix string) string
- func AddSuffixIfNot(str string, suffix string) string
- func CalculateMD5Hash(input string) string
- func CleanEmpty(str string) string
- func CompareIgnoreCase(str1 string, str2 string) int
- func Contains(value string, searchStr string) bool
- func ContainsAll(str string, searchStrs []string) bool
- func ContainsAny(value string, searchStrs []string) bool
- func ContainsAnyIgnoreCase(str string, searchStrs []string) bool
- func ContainsBlank(str string) bool
- func ContainsIgnoreCase(value string, searchStr string) bool
- func Count(str string, searchStr string) int
- func Cut(str string, n int) []string
- func EndWith(str string, suffix string) bool
- func EndWithAny(str string, suffixes []string) bool
- func EndWithAnyIgnoreCase(str string, suffixes []string) bool
- func EndWithIgnoreCase(str string, suffix string) bool
- func Equals(str1 string, str2 string) bool
- func EqualsAny(str1 string, str2 []string) bool
- func EqualsAnyIgnoreCase(str1 string, str2 []string) bool
- func EqualsAt(value string, position int, subStr string) bool
- func EqualsIgnoreCase(str1 string, str2 string) bool
- func ExtractValue(extra string, key string, searchPrefix string) string
- func Fill(str string, char string, length int, isPre bool) string
- func FillAfter(str string, char string, length int) string
- func FillBefore(str string, char string, length int) string
- func Format(template string, params map[string]interface{}) string
- func GetContainsStr(str string, searchStrs []string) string
- func Hide(str string, startInclude int, endExclude int) string
- func IndexOf(str string, subStr string) int
- func IndexOfByRange(str string, subStr string, start int, end int) int
- func IndexOfByRangeStart(str string, subStr string, start int) int
- func IndexOfIgnoreCase(str string, subStr string) int
- func IndexOfIgnoreCaseByRange(str string, subStr string, start int) int
- func IndexedFormat(template string, params []interface{}) string
- func InsertSpaces(str string, interval int) string
- func LastIndexOf(str string, subStr string) int
- func LastIndexOfByRangeStart(str string, subStr string, start int) int
- func LastIndexOfIgnoreCase(str string, subStr string) int
- func Length(str string) int
- func OrdinalIndexOf(str string, subStr string, ordinal int, start ...int) int
- func Pad(input string, minLength int, paddler ...*Paddler) string
- func RemoveAll(str string, strToRemove string) string
- func RemoveAllLineBreaks(str string) string
- func RemoveAny(str string, strsToRemove []string) string
- func RemovePrefix(str string, prefix string) string
- func RemovePrefixIgnoreCase(str string, prefix string) string
- func RemoveSuffix(str string, suffix string) string
- func RemoveSuffixIgnoreCase(str string, suffix string) string
- func Repeat(str string, count int) string
- func RepeatAndJoin(str string, delimiter string, count int) string
- func RepeatByLength(str string, padLen int) string
- func Replace(source string, searchStr string, replacement string, replaceCount int) string
- func ReplaceAll(source string, searchStr string, replacement string) string
- func ReplaceAllIgnoreCase(source string, searchStr string, replacement string) string
- func ReplaceIgnoreCase(source string, searchStr string, replacement string, replaceCount int) string
- func ReplaceSpecialChars(str string, replaceValue rune) string
- func ReplaceWithIndex(str string, startIndex int, endIndex int, replacedStr string) string
- func ReplaceWithMatcher(str string, regex string, replaceFun func(string) string) string
- func Reverse(str string) string
- func SafeIndexOfByRange(str string, subStr string, options ...func(*searchOptions)) (index int)
- func SetPadPosition(p *Paddler, position PadPosition)
- func Split(str string, separator string) []string
- func SplitAfterMapping[T any](str string, separator string, mapping func(s string) (T, error)) []T
- func SplitByLen(str string, length int) []string
- func SplitLimit(str string, separator string, limit int) []string
- func SplitTrim(str string, separator string) []string
- func SplitTrimLimit(str string, separator string, limit int) []string
- func StartWith(str string, prefix string) bool
- func StartWithAny(str string, prefixes []string) bool
- func StartWithAnyIgnoreCase(str string, prefixes []string) bool
- func StartWithIgnoreCase(str string, prefix string) bool
- func SubAfter(str string, separator string, isLastSeparator bool) string
- func SubBefore(str string, separator string, isLastSeparator bool) string
- func SubBetween(str string, before string, after string) string
- func SubBetweenAll(str string, prefix string, suffix string) []string
- func Trim(str string) string
- func TrimEnd(str string) string
- func TrimStart(str string) string
- func Truncate(str string, maxBytes int) string
- func TruncateAppendEllipsis(str string, maxBytes int) string
- func WithEnd(end int) func(*searchOptions)
- func WithStart(start int) func(*searchOptions)
- type PadPosition
- type Paddler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddPrefixIfNot ¶
AddPrefixIfNot 如果给定字符串不是以prefix开头的,在开头补充 prefix
func AddSuffixIfNot ¶
AddSuffixIfNot 如果给定字符串不是以suffix结尾的,在尾部补充 suffix
func CalculateMD5Hash ¶
CalculateMD5Hash 计算string md5 hash值
func ContainsAll ¶
ContainsAll 检查指定字符串中是否含给定的所有字符串
func ContainsAny ¶
ContainsAny 查找指定字符串是否包含指定字符串列表中的任意一个字符串
func ContainsAnyIgnoreCase ¶
ContainsAnyIgnoreCase 找指定字符串是否包含指定字符串列表中的任意一个字符串(忽略大小写)
func ContainsBlank ¶
ContainsBlank 给定字符串是否包含空白符(空白符包括空格、制表符、全角空格和不间断空格)
func ContainsIgnoreCase ¶
ContainsIgnoreCase 指定字符是否在字符串中出现过(忽略大小写)
func EndWithAny ¶
EndWithAny 给定字符串是否以任何一个字符串结尾 给定字符串和数组为空都返回false
func EndWithAnyIgnoreCase ¶
EndWithAnyIgnoreCase 给定字符串是否以任何一个字符串结尾(忽略大小写) 给定字符串和数组为空都返回false
func EndWithIgnoreCase ¶
EndWithIgnoreCase 是否以指定字符串结尾,忽略大小写
func EqualsAnyIgnoreCase ¶
EqualsAnyIgnoreCase 给定字符串是否与提供的中任一字符串相同(忽略大小写),相同则返回true,没有相同的返回false; 如果参与比对的字符串列表为空,返回false
func EqualsIgnoreCase ¶
EqualsIgnoreCase 比较2个字符串(大小写不敏感)
func ExtractValue ¶
ExtractValue 从给定的字符串中提取指定的键的值
func FillBefore ¶
FillBefore 将已有字符串填充为规定长度,如果已有字符串超过这个长度则返回这个字符串
func Format ¶
Format 通过map中的参数 格式化字符串 map = {a: "aValue", b: "bValue"} format("{a} and {b}", map) ---=》 aValue and bValue
func GetContainsStr ¶
GetContainsStr 查找指定字符串是否包含指定字符串列表中的任意一个字符串,如果包含返回找到的第一个字符串 不存在返回空串
func IndexOfByRange ¶
IndexOfByRange 指定范围内查找指定字符
func IndexOfByRangeStart ¶
IndexOfByRangeStart 指定范围内查找指定字符
func IndexOfIgnoreCase ¶
IndexOfIgnoreCase 返回字符在原始字符串的下标(大小写不敏感)
func IndexOfIgnoreCaseByRange ¶
IndexOfIgnoreCaseByRange 从指定下标开始,返回在字符串中的下标 (大小不敏感)
func IndexedFormat ¶
IndexedFormat 有序的格式化文本,使用{number}做为占位符 通常使用:format("this is {0} for {1}", "a", "b") =》 this is a for b
func InsertSpaces ¶
InsertSpaces 插入空值 InsertSpaces 插入空值
func LastIndexOfByRangeStart ¶
LastIndexOfByRangeStart 从指定下标开始,返回最后出现指定字符串的下标
func LastIndexOfIgnoreCase ¶
LastIndexOfIgnoreCase 返回最后出现指定字符串的下标(大小写不敏感)
func OrdinalIndexOf ¶
OrdinalIndexOf 返回字符串 subStr 在字符串 str 中第 ordinal 次出现的位置。 如果 str="" 或 subStr=" 或 ordinal≥0 则返回-1
func RemoveAllLineBreaks ¶
RemoveAllLineBreaks 去除所有换行符,包括:\r \n
func RemovePrefixIgnoreCase ¶
RemovePrefixIgnoreCase 忽略大小写去掉指定前缀
func RemoveSuffixIgnoreCase ¶
RemoveSuffixIgnoreCase 去掉指定后缀(忽略大小写)
func RepeatAndJoin ¶
RepeatAndJoin 重复某个字符串并通过分界符连接
func RepeatByLength ¶
RepeatByLength 重复某个字符串到指定长度
func ReplaceAll ¶
ReplaceAll 替换字符串
func ReplaceAllIgnoreCase ¶
ReplaceAllIgnoreCase 替换字符串
func ReplaceIgnoreCase ¶
func ReplaceIgnoreCase(source string, searchStr string, replacement string, replaceCount int) string
ReplaceIgnoreCase 替换字符串
func ReplaceSpecialChars ¶
ReplaceSpecialChars 去掉特殊符号、转为自定义
func ReplaceWithIndex ¶
ReplaceWithIndex 按照指定区间替换字符串 startIndex 开始位置(包含) endIndex 结束位置(不包含)
func ReplaceWithMatcher ¶
ReplaceWithMatcher 通过正则表达式替换字符串
func SafeIndexOfByRange ¶
SafeIndexOfByRange 在指定范围内查找指定字符,避免下标溢出
func SetPadPosition ¶
func SetPadPosition(p *Paddler, position PadPosition)
func SplitAfterMapping ¶
SplitAfterMapping 切分字符串,切分之后通过mapping转换并返回
func SplitLimit ¶
SplitLimit 分割字符串,限制分片数
func SplitTrimLimit ¶
SplitTrimLimit 切分字符串,去除切分后每个元素两边的空白符,去除空白项,限制分片数
func StartWithAny ¶
StartWithAny 给定字符串是否以任何一个字符串开始; 给定字符串和数组为空都返回false
func StartWithAnyIgnoreCase ¶
StartWithAnyIgnoreCase 给定字符串是否以任何一个字符串开始(忽略大小写) 给定字符串和数组为空都返回false
func StartWithIgnoreCase ¶
StartWithIgnoreCase 字符串是否以给定字符开始-忽略大小写
func SubBefore ¶
SubBefore 截取分隔字符串之前的字符串,不包括分隔字符串 isLastSeparator - 是否查找最后一个分隔字符串(多次出现分隔字符串时选取最后一个),true为选取最后一个
func SubBetween ¶
SubBetween 截取指定字符串中间部分,不包括标识字符串
func SubBetweenAll ¶
SubBetweenAll 截取指定字符串多段中间部分,不包括标识字符串
func TruncateAppendEllipsis ¶
TruncateAppendEllipsis 截断字符串,使用不超过maxBytes长度。截断后自动追加省略号(...) 用于存储数据库varchar且编码为UTF-8的字段
Types ¶
type Paddler ¶
type Paddler struct {
Position PadPosition
}