strings.go 221 B

12345678910111213
  1. package utils
  2. func ReplaceSub(s, sub string, start, count int) string {
  3. var newStr string
  4. for i, v := range s {
  5. var p = string(v)
  6. if i >= start && i < start+count {
  7. p = sub
  8. }
  9. newStr += p
  10. }
  11. return newStr
  12. }