pattern := "/admin/index"
func Count(s,sep string) int
统计字符串sep在字符串s中有几个,sep为空则返回s中字符的个数+1
func HasPrefix(s,prefix string) bool
检查字符串s是否以prefix前缀开始
func Index(s,sep string) int
返回sep在字符串s中的索引值,如果s中没有sep则返回-1
func Split(s,sep string) []string
Split通过sep把s分割成几个小的string,返回分割后的得到的string组成的slice
例如:
parts := strings.Split(pattern, "/") //打印:["" "admin" "index"]
parts := strings.Split(pattern, "") //打印:["/" "a" "d" "m" "i" "n" "/" "i" "n" "d" "e" "x"]
func SplitAfter(s,sep string) []string
SplitAfter通过sep把s分割成几个小的string(string尾部包含sep),返回分割后的得到的string组成的slice
parts := strings.SplitAfter(pattern, "/") //打印:["/" "admin/" "index"]
parts := strings.SplitAfter(pattern, "") //打印:["/" "a" "d" "m" "i" "n" "/" "i" "n" "d" "e" "x"]
func TrimRight(sstring,cutsetstring)string
修剪掉字符串s最右边的cutset
func Join(a []string,sep string) string
把sep添加到a数组的每个元素之间,并返回一个字符串
原文链接:https://www.f2er.com/go/191420.html