golang中的字符串操作strings.Replace
package main
import (
"fmt"
"strings"
)
//golang字符串操作
func main(){
s := "Hello world hello world"
str := "Hello"
//var s = []string{"11","22","33"}
//返回s的副本,并将副本中的old字符串替换为new字符串,替换次数为n次,
//如果n为-1,则全部替换;如果 old 为空,则在副本的每个字符之间都插入一个new
ret := strings.Replace(s,"hello",str,1)
fmt.Println(ret) // Hello world Hello world
}