1、TrimRight/Left:
函数定义:
// TrimRight returns a slice of the string s, with all trailing
// Unicode code points contained in cutset removed.
//从右往左删除s中所有包含在cutset里面的字符;直到遇到不包含在cutset里面的字符为止
func TrimRight(s string, cutset string) string
// TrimLeft returns a slice of the string s with all leading
// Unicode code points contained in cutset removed.
//从左往右删除s中所有包含在cutset里面的字符;直到遇到不包含在cutset里面的字符为止
func TrimLeft(s string, cutset string) string
fmt.Println(strings.TrimRight("abcbab", "ab"))
输出:abc
fmt.Println(strings.TrimLeft("abcbab", "ab"))
输出:cbab
2、TrimSuffix/Pefix:
函数定义: // TrimSuffix returns s without the provided trailing suffix string. // If s doesn't end with suffix, s is returned unchanged. // 删除后缀 func TrimSuffix(s, suffix []byte) []byte
有疑问加站长微信联系(非本文作者))
