Golang取中间字符串

//取中间字符串

func Between(str, starting, ending string) string {

s := strings.Index(str, starting)

if s < 0 {

return ""

}

s += len(starting)

e := strings.Index(str[s:], ending)

if e < 0 {

return ""

}

return str[s : s+e]

}

你可能感兴趣的:(Golang取中间字符串)