package main
import (
"fmt"
"strings"
)
func main() {
a := "大大1122佛挡杀佛大大"
c := Substr(a, "大大1", "杀")
fmt.Println(c)
}
func Substr(str, startStr, endStr string) string {
s := strings.Index(str, (startStr)) + len(startStr)
e := strings.Index(str, (endStr))
if s == -1 {
return ""
}
if e == -1 {
return string(str[s:])
}
return string(str[s:e])
}
def substr(stringStr,start,end):
m=stringStr.index(start)
n=stringStr.index(end)
if m==-1 :
return""
if n==-1:
return stringStr(str[m:])
return stringStr[m:n]
a= "大大1122佛挡杀佛大大"
print(substr(a,"大大1","杀"))
有疑问加站长微信联系(非本文作者)
![](https://static.golangjob.cn/static/img/footer.png?imageView2/2/w/280)