Documentation ¶
Overview ¶
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-11-22 10:07:57 * @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-11-22 10:07:57 * @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-11-09 20:06:12 * @FilePath: \go-toolbox\pkg\stringx\regexp.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-22 10:07:57 * @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-11-22 10:07:57 * @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-11-22 10:15:50 * @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-11-22 10:16:00 * @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-11-22 10:37:52 * @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 Coalesce(s ...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 ConvertCharacterStyle(input string, caseType CharacterStyle) string
- 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 HasLocalIP(ip string) bool
- 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 IsChineseCharacter(str string) (isContains bool, count int)
- func IsGlobalUnicast(ip string) bool
- func IsLinkLocal(ip net.IP) bool
- func IsTrueString(s string) bool
- func IsUniqueLocalAddress(ip net.IP) bool
- 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 MatchEnCharacterDotUnderLine(str string) bool
- 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 RemoveSymbols(s 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 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, maxChars int) string
- func WithEnd(end int) func(*searchOptions)
- func WithStart(start int) func(*searchOptions)
- type AnyRegs
- func (g *AnyRegs) IsHex(input string) bool
- func (g *AnyRegs) MatchChineseIDCardNumber(id string) bool
- func (g *AnyRegs) MatchChinesePhoneNumber(str string) bool
- func (g *AnyRegs) MatchContainChineseCharacter(str string) bool
- func (g *AnyRegs) MatchDoubleByte(input string) bool
- func (g *AnyRegs) MatchEmail(str string) bool
- func (g *AnyRegs) MatchEmptyLine(input string) bool
- func (g *AnyRegs) MatchEnCharacter(str string) bool
- func (g *AnyRegs) MatchGeNNumber(str string, n int) bool
- func (g *AnyRegs) MatchIPv4(input string) bool
- func (g *AnyRegs) MatchIPv6(input string) bool
- func (g *AnyRegs) MatchIntOrFloat(str string) bool
- func (g *AnyRegs) MatchIsContainSpecialCharacter(str string) bool
- func (g *AnyRegs) MatchLenNNumber(str string, n int) bool
- func (g *AnyRegs) MatchLowerEnCharacter(str string) bool
- func (g *AnyRegs) MatchMNIntervalNumber(str string, m, n int) bool
- func (g *AnyRegs) MatchMNNovelsOfRealNumber(str string, m, n int) bool
- func (g *AnyRegs) MatchNLeCharacter(str string, n int) bool
- func (g *AnyRegs) MatchNNovelsOfRealNumber(str string, n int) bool
- func (g *AnyRegs) MatchNanZeroNegNumber(str string) bool
- func (g *AnyRegs) MatchNanZeroNumber(str string) bool
- func (g *AnyRegs) MatchNumber(str string) bool
- func (g *AnyRegs) MatchNumberEnCharacter(str string) bool
- func (g *AnyRegs) MatchNumberEnUnderscores(str string) bool
- func (g *AnyRegs) MatchPass1(str string, m, n int) bool
- func (g *AnyRegs) MatchPass2(str string) bool
- func (g *AnyRegs) MatchStartingWithNonZero(str string) bool
- func (g *AnyRegs) MatchTime(input string) bool
- func (g *AnyRegs) MatchUpEnCharacter(str string) bool
- type CharacterStyle
- type PadPosition
- type Paddler
- type StringX
- func (s *StringX) AddPrefixIfNotChain(prefix string) *StringX
- func (s *StringX) AddSuffixIfNotChain(prefix string) *StringX
- func (s *StringX) CleanEmptyChain() *StringX
- func (s *StringX) CoalesceChain(strs ...string) *StringX
- func (s *StringX) CompareIgnoreCaseChain(str2 string) int
- func (s *StringX) ContainsAllChain(searchStrs []string) bool
- func (s *StringX) ContainsAnyChain(searchStrs []string) bool
- func (s *StringX) ContainsAnyIgnoreCaseChain(searchStrs []string) bool
- func (s *StringX) ContainsBlankChain() bool
- func (s *StringX) ContainsChain(searchStr string) bool
- func (s *StringX) ContainsIgnoreCaseChain(searchStr string) bool
- func (s *StringX) ConvertCharacterStyleChain(caseType CharacterStyle) *StringX
- func (s *StringX) CountChain(searchStr string) int
- func (s *StringX) EqualsAnyChain(strs []string) bool
- func (s *StringX) EqualsAnyIgnoreCaseChain(strs []string) bool
- func (s *StringX) EqualsAtChain(position int, subStr string) bool
- func (s *StringX) EqualsChain(str2 string) bool
- func (s *StringX) EqualsIgnoreCaseChain(str2 string) bool
- func (s *StringX) FillAfterChain(char string, length int) *StringX
- func (s *StringX) FillBeforeChain(char string, length int) *StringX
- func (s *StringX) FormatChain(params map[string]interface{}) *StringX
- func (s *StringX) GetContainsStrChain(searchStrs []string) string
- func (s *StringX) HideChain(startInclude int, endExclude int) *StringX
- func (s *StringX) IndexedFormatChain(params []interface{}) *StringX
- func (s *StringX) InsertSpacesChain(interval int) *StringX
- func (s *StringX) LengthChain() int
- func (s *StringX) RemoveAllChain(strToRemove string) *StringX
- func (s *StringX) RemoveAllLineBreaksChain() *StringX
- func (s *StringX) RemoveAnyChain(strsToRemove []string) *StringX
- func (s *StringX) RemovePrefixChain(prefix string) *StringX
- func (s *StringX) RemovePrefixIgnoreCaseChain(prefix string) *StringX
- func (s *StringX) RemoveSuffixChain(suffix string) *StringX
- func (s *StringX) RemoveSuffixIgnoreCaseChain(suffix string) *StringX
- func (s *StringX) RepeatAndJoinChain(delimiter string, count int) *StringX
- func (s *StringX) RepeatByLengthChain(padLen int) *StringX
- func (s *StringX) RepeatChain(count int) *StringX
- func (s *StringX) ReplaceAllChain(searchStr string, replacement string) *StringX
- func (s *StringX) ReplaceChain(searchStr string, replacement string, replaceCount int) *StringX
- func (s *StringX) ReplaceSpecialCharsChain(replaceValue rune) *StringX
- func (s *StringX) ReplaceWithMatcherChain(regex string, replaceFun func(string) string) *StringX
- func (s *StringX) ReverseChain() *StringX
- func (s *StringX) SubAfterChain(separator string, isLastSeparator bool) *StringX
- func (s *StringX) SubBeforeChain(separator string, isLastSeparator bool) *StringX
- func (s *StringX) SubBetweenChain(before string, after string) *StringX
- func (s *StringX) TrimChain() *StringX
- func (s *StringX) TrimEndChain() *StringX
- func (s *StringX) TrimStartChain() *StringX
- func (s *StringX) TruncateAppendEllipsisChain(maxBytes int) *StringX
- func (s *StringX) TruncateChain(maxBytes int) *StringX
- func (s *StringX) Value() string
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 CompareIgnoreCase ¶
CompareIgnoreCase 比较两个字符串,用于排序(大小写不敏感)
func ContainsAll ¶
ContainsAll 检查指定字符串中是否含给定的所有字符串
func ContainsAny ¶
ContainsAny 查找指定字符串是否包含指定字符串列表中的任意一个字符串
func ContainsAnyIgnoreCase ¶
ContainsAnyIgnoreCase 找指定字符串是否包含指定字符串列表中的任意一个字符串(忽略大小写)
func ContainsBlank ¶
ContainsBlank 给定字符串是否包含空白符(空白符包括空格、制表符、全角空格和不间断空格)
func ContainsIgnoreCase ¶
ContainsIgnoreCase 指定字符是否在字符串中出现过(忽略大小写)
func ConvertCharacterStyle ¶ added in v0.11.6
func ConvertCharacterStyle(input string, caseType CharacterStyle) string
ConvertCharacterStyle 根据指定的 CharacterStyle 将字符串转换为相应的格式
func EndWithAny ¶
EndWithAny 给定字符串是否以任何一个字符串结尾 给定字符串和数组为空都返回false
func EndWithAnyIgnoreCase ¶
EndWithAnyIgnoreCase 给定字符串是否以任何一个字符串结尾(忽略大小写) 给定字符串和数组为空都返回false
func EndWithIgnoreCase ¶
EndWithIgnoreCase 是否以指定字符串结尾,忽略大小写
func EqualsAnyIgnoreCase ¶
EqualsAnyIgnoreCase 给定字符串是否与提供的中任一字符串相同(忽略大小写)
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 IsChineseCharacter ¶ added in v0.11.5
IsChineseCharacter 检查字符串是否为纯汉字
func IsGlobalUnicast ¶ added in v0.11.5
IsGlobalUnicast 检查给定的 IP 地址是否是全球单播地址
func IsUniqueLocalAddress ¶ added in v0.11.5
IsUniqueLocalAddress 检查给定的 IP 是否为唯一本地地址(ULA)
func LastIndexOfByRangeStart ¶
LastIndexOfByRangeStart 从指定下标开始,返回最后出现指定字符串的下标
func LastIndexOfIgnoreCase ¶
LastIndexOfIgnoreCase 返回最后出现指定字符串的下标(大小写不敏感)
func MatchEnCharacterDotUnderLine ¶ added in v0.11.5
MatchEnCharacterDotUnderLine 检查字符串是否只包含字母、数字、点号和下划线
func OrdinalIndexOf ¶
OrdinalIndexOf 返回字符串 subStr 在字符串 str 中第 ordinal 次出现的位置。 如果 str="" 或 subStr=" 或 ordinal≥0 则返回-1
func RemoveAllLineBreaks ¶
RemoveAllLineBreaks 去除所有换行符,包括:\r \n
func RemovePrefixIgnoreCase ¶
RemovePrefixIgnoreCase 忽略大小写去掉指定前缀
func RemoveSuffixIgnoreCase ¶
RemoveSuffixIgnoreCase 去掉指定后缀(忽略大小写)
func RemoveSymbols ¶ added in v0.11.5
RemoveSymbols 使用正则表达式去掉字符串中的所有符号
func RepeatAndJoin ¶
RepeatAndJoin 重复某个字符串并通过分界符连接
func RepeatByLength ¶
RepeatByLength 重复某个字符串到指定长度
func ReplaceAll ¶
ReplaceAll 替换字符串
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 截断字符串,使用不超过maxChars字符长度。截断后自动追加省略号(...) 用于存储数据库varchar且编码为UTF-8的字段
Types ¶
type AnyRegs ¶ added in v0.11.5
type AnyRegs struct {
// contains filtered or unexported fields
}
AnyRegs 包含各种正则表达式的结构体
func NewAnyRegs ¶ added in v0.11.5
func NewAnyRegs() *AnyRegs
NewAnyRegs 创建一个新的 AnyRegs 实例,并编译所有正则表达式
func (*AnyRegs) MatchChineseIDCardNumber ¶ added in v0.11.5
MatchChineseIDCardNumber 检查字符串是否为有效的大陆身份证号
func (*AnyRegs) MatchChinesePhoneNumber ¶ added in v0.11.5
MatchChinesePhoneNumber 检查字符串是否为有效的大陆手机号
func (*AnyRegs) MatchContainChineseCharacter ¶ added in v0.11.5
MatchContainChineseCharacter 检查字符串是否包含中文字符
func (*AnyRegs) MatchDoubleByte ¶ added in v0.11.5
MatchDoubleByte 检查字符串是否包含双字节字符(包括汉字)
func (*AnyRegs) MatchEmail ¶ added in v0.11.5
MatchEmail 检查字符串是否为有效的email
func (*AnyRegs) MatchEmptyLine ¶ added in v0.11.5
MatchEmptyLine 检查字符串是否为空行
func (*AnyRegs) MatchEnCharacter ¶ added in v0.11.5
MatchEnCharacter 检查字符串是否为纯英文字符串(大小写不敏感)
func (*AnyRegs) MatchGeNNumber ¶ added in v0.11.5
MatchGeNNumber 检查字符串是否为长度不小于n的纯数字
func (*AnyRegs) MatchIntOrFloat ¶ added in v0.11.5
MatchIntOrFloat 检查字符串是否为整数或小数
func (*AnyRegs) MatchIsContainSpecialCharacter ¶ added in v0.11.5
MatchIsContainSpecialCharacter 检查字符串是否包含特殊字符
func (*AnyRegs) MatchLenNNumber ¶ added in v0.11.5
MatchLenNNumber 检查字符串是否为长度为n的纯数字
func (*AnyRegs) MatchLowerEnCharacter ¶ added in v0.11.5
MatchLowerEnCharacter 检查字符串是否为纯小写英文字符串
func (*AnyRegs) MatchMNIntervalNumber ¶ added in v0.11.5
MatchMNIntervalNumber 检查字符串是否为长度在m到n之间的纯数字
func (*AnyRegs) MatchMNNovelsOfRealNumber ¶ added in v0.11.5
MatchMNNovelsOfRealNumber 检查字符串是否为m到n位小数的正实数
func (*AnyRegs) MatchNLeCharacter ¶ added in v0.11.5
MatchNLeCharacter 检查字符串是否为长度为n的字符
func (*AnyRegs) MatchNNovelsOfRealNumber ¶ added in v0.11.5
MatchNNovelsOfRealNumber 检查字符串是否为有n位小数的正实数
func (*AnyRegs) MatchNanZeroNegNumber ¶ added in v0.11.5
MatchNanZeroNegNumber 检查字符串是否为非零的负整数
func (*AnyRegs) MatchNanZeroNumber ¶ added in v0.11.5
MatchNanZeroNumber 检查字符串是否为非零的正整数
func (*AnyRegs) MatchNumber ¶ added in v0.11.5
MatchNumber 检查字符串是否为纯数字
func (*AnyRegs) MatchNumberEnCharacter ¶ added in v0.11.5
MatchNumberEnCharacter 检查字符串是否由数字和26个英文字母组成(大小写不敏感)
func (*AnyRegs) MatchNumberEnUnderscores ¶ added in v0.11.5
MatchNumberEnUnderscores 检查字符串是否由数字和26个英文字母或下划线组成(大小写不敏感)
func (*AnyRegs) MatchPass1 ¶ added in v0.11.5
MatchPass1 检查密码1是否符合规则:由数字、26个英文字母或下划线组成的英文开头的字符串,长度在m到n位之间
func (*AnyRegs) MatchPass2 ¶ added in v0.11.5
MatchPass2 检查密码2是否符合规则: 密码长度至少为8个字符。 包含至少一个小写字母。 包含至少一个大写字母。 包含至少一个数字。 包含至少一个特殊字符(例如 !@#$%^&*() 等)
func (*AnyRegs) MatchStartingWithNonZero ¶ added in v0.11.5
MatchStartingWithNonZero 检查字符串是否为非零开头的纯数字
func (*AnyRegs) MatchUpEnCharacter ¶ added in v0.11.5
MatchUpEnCharacter 检查字符串是否为纯大写英文字符串
type CharacterStyle ¶ added in v0.11.6
type CharacterStyle int
const ( SnakeCharacterStyle CharacterStyle = iota // 表示蛇形命名法(例如:hello_world) StudlyCharacterStyle // 表示每个单词首字母大写的风格(例如:HelloWorld) CamelCharacterStyle // 表示驼峰命名法(例如:helloWorld) )
type Paddler ¶
type Paddler struct {
Position PadPosition
}
type StringX ¶ added in v0.11.12
type StringX struct {
// contains filtered or unexported fields
}
StringX 是一个结构体,用于封装字符串值并提供操作方法。
func (*StringX) AddPrefixIfNotChain ¶ added in v0.11.12
AddPrefixIfNotChain 如果给定字符串不是以prefix开头的(链式调用)
func (*StringX) AddSuffixIfNotChain ¶ added in v0.11.12
AddSuffixIfNotChain 如果给定字符串不是以suffix结尾的,在尾部补充 suffix(链式调用)
func (*StringX) CleanEmptyChain ¶ added in v0.11.12
CleanEmptyChain 清除空白串(链式调用)
func (*StringX) CoalesceChain ¶ added in v0.11.12
CoalesceChain 高性能字符串拼接(链式调用)
func (*StringX) CompareIgnoreCaseChain ¶ added in v0.11.12
CompareIgnoreCaseChain 比较两个字符串(链式调用,用于排序,忽略大小写)
func (*StringX) ContainsAllChain ¶ added in v0.11.12
ContainsAllChain 检查指定字符串中是否含给定的所有字符串(链式调用)
func (*StringX) ContainsAnyChain ¶ added in v0.11.12
ContainsAnyChain 查找指定字符串是否包含指定字符串列表中的任意一个字符串(链式调用)
func (*StringX) ContainsAnyIgnoreCaseChain ¶ added in v0.11.12
ContainsAnyIgnoreCaseChain 找指定字符串是否包含指定字符串列表中的任意一个字符串(链式调用,忽略大小写)
func (*StringX) ContainsBlankChain ¶ added in v0.11.12
ContainsBlankChain 给定字符串是否包含空白符(链式调用)
func (*StringX) ContainsChain ¶ added in v0.11.12
ContainsChain 指定字符是否在字符串中出现过(链式调用)
func (*StringX) ContainsIgnoreCaseChain ¶ added in v0.11.12
ContainsIgnoreCaseChain 指定字符是否在字符串中出现过(链式调用,忽略大小写)
func (*StringX) ConvertCharacterStyleChain ¶ added in v0.11.12
func (s *StringX) ConvertCharacterStyleChain(caseType CharacterStyle) *StringX
ConvertCharacterStyleChain 根据指定的 CharacterStyle 将字符串转换为相应的格式(链式调用)
func (*StringX) CountChain ¶ added in v0.11.12
CountChain 统计指定内容中包含指定字符串的数量(链式调用)
func (*StringX) EqualsAnyChain ¶ added in v0.11.12
EqualsAnyChain 给定字符串是否与提供的中任一字符串相同(链式调用)
func (*StringX) EqualsAnyIgnoreCaseChain ¶ added in v0.11.12
EqualsAnyIgnoreCaseChain 给定字符串是否与提供的中任一字符串相同(链式调用,忽略大小写)
func (*StringX) EqualsAtChain ¶ added in v0.11.12
EqualsAtChain 字符串指定位置的字符是否与给定字符相同(链式调用)
func (*StringX) EqualsChain ¶ added in v0.11.12
EqualsChain 比较2个字符串(链式调用)
func (*StringX) EqualsIgnoreCaseChain ¶ added in v0.11.12
EqualsIgnoreCaseChain 比较2个字符串(链式调用,忽略大小写)
func (*StringX) FillAfterChain ¶ added in v0.11.12
FillAfterChain 将已有字符串填充为规定长度(链式调用)
func (*StringX) FillBeforeChain ¶ added in v0.11.12
FillBeforeChain 将已有字符串填充为规定长度(链式调用)
func (*StringX) FormatChain ¶ added in v0.11.12
FormatChain 通过map中的参数格式化字符串(链式调用)
func (*StringX) GetContainsStrChain ¶ added in v0.11.12
GetContainsStrChain 查找指定字符串是否包含指定字符串列表中的任意一个字符串(链式调用)
func (*StringX) IndexedFormatChain ¶ added in v0.11.12
IndexedFormatChain 有序的格式化文本(链式调用)
func (*StringX) InsertSpacesChain ¶ added in v0.11.12
InsertSpacesChain 插入空值(链式调用)
func (*StringX) LengthChain ¶ added in v0.11.12
LengthChain 计算长度(链式调用)
func (*StringX) RemoveAllChain ¶ added in v0.11.12
RemoveAllChain 移除字符串中所有给定字符串(链式调用)
func (*StringX) RemoveAllLineBreaksChain ¶ added in v0.11.12
RemoveAllLineBreaksChain 去除所有换行符(链式调用)
func (*StringX) RemoveAnyChain ¶ added in v0.11.12
RemoveAnyChain 移除字符串中所有给定字符串(链式调用)
func (*StringX) RemovePrefixChain ¶ added in v0.11.12
RemovePrefixChain 去掉指定前缀(链式调用)
func (*StringX) RemovePrefixIgnoreCaseChain ¶ added in v0.11.12
RemovePrefixIgnoreCaseChain 忽略大小写去掉指定前缀(链式调用)
func (*StringX) RemoveSuffixChain ¶ added in v0.11.12
RemoveSuffixChain 去掉指定后缀(链式调用)
func (*StringX) RemoveSuffixIgnoreCaseChain ¶ added in v0.11.12
RemoveSuffixIgnoreCaseChain 去掉指定后缀(链式调用,忽略大小写)
func (*StringX) RepeatAndJoinChain ¶ added in v0.11.12
RepeatAndJoinChain 重复某个字符串并通过分界符连接(链式调用)
func (*StringX) RepeatByLengthChain ¶ added in v0.11.12
RepeatByLengthChain 重复某个字符串到指定长度(链式调用)
func (*StringX) RepeatChain ¶ added in v0.11.12
RepeatChain 重复字符串(链式调用)
func (*StringX) ReplaceAllChain ¶ added in v0.11.12
ReplaceAllChain 替换字符串(链式调用)
func (*StringX) ReplaceChain ¶ added in v0.11.12
ReplaceChain 替换字符串(链式调用)
func (*StringX) ReplaceSpecialCharsChain ¶ added in v0.11.12
ReplaceSpecialCharsChain 去掉特殊符号、转为自定义(链式调用)
func (*StringX) ReplaceWithMatcherChain ¶ added in v0.11.12
ReplaceWithMatcherChain 通过正则表达式替换字符串(链式调用)
func (*StringX) ReverseChain ¶ added in v0.11.12
ReverseChain 反转字符串(链式调用)
func (*StringX) SubAfterChain ¶ added in v0.11.12
SubAfterChain 截取分隔字符串之后的字符串(链式调用)
func (*StringX) SubBeforeChain ¶ added in v0.11.12
SubBeforeChain 截取分隔字符串之前的字符串(链式调用)
func (*StringX) SubBetweenChain ¶ added in v0.11.12
SubBetweenChain 截取指定字符串中间部分(链式调用)
func (*StringX) TrimEndChain ¶ added in v0.11.12
TrimEndChain 除去字符串尾部的空白(链式调用)
func (*StringX) TrimStartChain ¶ added in v0.11.12
TrimStartChain 除去字符串头部的空白(链式调用)
func (*StringX) TruncateAppendEllipsisChain ¶ added in v0.11.12
TruncateAppendEllipsisChain 截断字符串(链式调用)
func (*StringX) TruncateChain ¶ added in v0.11.12
TruncateChain 截断字符串(链式调用)