Go 标准包 strings 学习(6) Join,LastIndex,LastIndexAny,LastIndexByte,L
https://pkg.go.dev/strings@go1.20.4#Join
func Join
Join concatenates the elements of its first argument to create a single string. The separator string sep is placed between elements in the resulting string.
Join将其第一个参数的元素连接起来以创建单个字符串。分隔字符串sep放置在结果字符串的元素之间。
例子
输出
foo, bar, baz
理解:将一个切片里面的数据转为一整个字符串,并使用传入的第二个string分割

func LastIndex
LastIndex returns the index of the last instance of substr in s, or -1 if substr is not present in s.
LastIndex返回s中substr最后一个实例的索引,如果substr不存在于s中,则返回-1。
例子
输出
0 3 -1
理解
传入2个字符串,第一个是需要被搜索的字符串,第二个是需要在第一个字符串里面进行检索的字符串,返回第二个字符串在第一个字符串中最后一次出现的下标位置

func LastIndexAny
LastIndexAny returns the index of the last instance of any Unicode code point from chars in s, or -1 if no Unicode code point from chars is present in s.
LastIndexAny返回s中字符的任何Unicode码点的最后一个实例的索引,如果s中没有字符的Unicode码点,则返回-1。
例子
输出
4 8 -1
理解
返回第二个字符串里的任意一个字符,在第一个字符串中,最后一次出现的下标

func LastIndexByte
LastIndexByte returns the index of the last instance of c in s, or -1 if c is not present in s.
LastIndexByte返回s中c的最后一个实例的索引,如果s中不存在c,则返回-1。
例子
输出
10 8 -1
理解
返回输入的字符在字符串中最后一次出现的下标位置

func LastIndexFunc
LastIndexFunc returns the index into s of the last Unicode code point satisfying f(c), or -1 if none do.
LastIndexFunc返回满足f(c)的最后一个Unicode码点到s的索引,如果不满足则返回-1。
例子
输出
5 2 -1
理解
返回字符串在哪一个下标位置符合指定的规则