replace.go 259 B

123456789101112131415
  1. package main
  2. import (
  3. "fmt"
  4. "github.com/tal-tech/go-zero/core/stringx"
  5. )
  6. func main() {
  7. replacer := stringx.NewReplacer(map[string]string{
  8. "PHP": "PPT",
  9. "世界上": "吹牛",
  10. })
  11. fmt.Println(replacer.Replace("PHP是世界上最好的语言!"))
  12. }