第一次发帖,如有疑问评论或私信
// substr存在的次数,如果是空字符串返回s索引+1
func Count(s, substr string) int
// 出现空格拆分字符串,
func Fields(s string) []string
// 拆分满足asciiSpace字符
func FieldsFunc(s string, f func(rune) bool) []string
// 匹配前缀
func HasPrefix(s, prefix string) bool
// 匹配后缀
func HasSuffix(s, suffix string) bool
// 返回第一次实例的索引
func Index(s, substr string) int
// 返回第一次实例的索引
func IndexAny(s, chars string) int
// 只能匹配一个字符
func IndexByte(s string, c byte) int
// 只能匹配一个字符
func IndexRune(s string, r rune) int
// 拼接字符串
func Join(elems []string, sep string) string
// 重复s中的字符串
func Repeat(s string, count int) string
// 替换s中的字符串
func Replace(s, old, new string, n int) string
// 替换s中的字符串
func ReplaceAll(s, old, new string) string
// 切分
func Split(s, sep string) []string
// 切分
func SplitN(s, sep string, n int) []string
// 在sep+1索引后切分
func SplitAfter(s, sep string) []string
// 在sep+1索引后切分
func SplitAfterN(s, sep string, n int) []string
// 返回字符串s中满足函数f(r)==true字符首次出现的位置
func IndexFunc(s string, f func(rune) bool) int
// 返回字符串s中字符串substr最后一次出现的位置
func LastIndex(s, substr string) int
// 返回字符串s中字符串chars Unicode编码后最后一次出现的位置
func LastIndexAny(s, chars string) int
// 返回字符串s中字符串c Unicode编码后最后一次出现的位置
func LastIndexByte(s string, c byte) int
// 返回字符串s中字符串f Unicode编码后最后一次出现的位置
func LastIndexFunc(s string, f func(rune) bool) int
// 如果mapping条件成立替换s字符串
func Map(mapping func(rune) rune, s string) string
大小写互转
// 首字母大写
func Title(s string) string
// 转小写
func ToLower(s string) string
// 转小写
func ToLowerSpecial(c unicode.SpecialCase, s string) string
// 转大写
func ToTitle(s string) string
// 转大写
func ToTitleSpecial(c unicode.SpecialCase, s string) string
// 转大写
func ToUpper(s string) string
// 转大写
func ToUpperSpecial(c unicode.SpecialCase, s string) string
字符串比较
// 字符串比较大小,a小于b返回-1,a大于b返回1,a等于b返回0
func Compare(a, b string) int
// substr字符串是否存在与s中
func Contains(s, substr string) bool
// 与上相反
func ContainsAny(s, chars string) bool
// r unicode编码是否存在与s中
func ContainsRune(s string, r rune) bool
// t字符串是否存在与s中,不敏感大小写
func EqualFold(s, t string) bool
去掉字符串
// 去掉左右字符串
func Trim(s, cutset string) string
// 去掉左右字符串
func TrimFunc(s string, f func(rune) bool) string
// 去掉右字符串
func TrimLeft(s, cutset string) string
// 去掉右字符串
func TrimLeftFunc(s string, f func(rune) bool) string
// 去掉前面字符串
func TrimPrefix(s, prefix string) string
// 去掉左字符串
func TrimRight(s, cutset string) string
// 去掉左字符串
func TrimRightFunc(s string, f func(rune) bool) string
// 去掉左右空格
func TrimSpace(s string) string
// 去掉后面字符串
func TrimSuffix(s, suffix string) string