qq_遁去的一_1
1-使用_, after, _ = strings.Cut(ms, p),试试这个:func removeFromPattern(p, ms string) (after string) { _, after, _ = strings.Cut(ms, p) // before and after sep. return}哪个用途strings.Index:// Cut slices s around the first instance of sep,// returning the text before and after sep.// The found result reports whether sep appears in s.// If sep does not appear in s, cut returns s, "", false.func Cut(s, sep string) (before, after string, found bool) { if i := Index(s, sep); i >= 0 { return s[:i], s[i+len(sep):], true } return s, "", false}2-使用strings.Index,试试这个:func removeFromPattern(p, ms string) string { i := strings.Index(ms, p) if i == -1 { return "" } return ms[i+len(p):]}3-使用strings.Split,试试这个:func removeFromPattern(p, ms string) string { a := strings.Split(ms, p) if len(a) != 2 { return "" } return a[1]}4-使用regexp,试试这个func removeFromPattern(p, ms string) string { a := regexp.MustCompile(p).FindStringSubmatch(ms) if len(a) < 2 { return "" } return a[1]}