package main import ( "fmt" "strings" ) func main() { s := "a-b-c-d" // replace every "-" fmt.Println(strings.ReplaceAll(s, "-", "_")) // replace only the first two fmt.Println(strings.Replace(s, "-", "_", 2)) }
substitute substrings