(str string, info []replaceInfo)
| 201 | } |
| 202 | |
| 203 | func strGsubDoReplace(str string, info []replaceInfo) string { |
| 204 | offset := 0 |
| 205 | buf := []byte(str) |
| 206 | for _, replace := range info { |
| 207 | oldlen := len(buf) |
| 208 | b1 := append([]byte(""), buf[0:offset+replace.Indicies[0]]...) |
| 209 | b2 := []byte("") |
| 210 | index2 := offset + replace.Indicies[1] |
| 211 | if index2 <= len(buf) { |
| 212 | b2 = append(b2, buf[index2:len(buf)]...) |
| 213 | } |
| 214 | buf = append(b1, replace.String...) |
| 215 | buf = append(buf, b2...) |
| 216 | offset += len(buf) - oldlen |
| 217 | } |
| 218 | return string(buf) |
| 219 | } |
| 220 | |
| 221 | func strGsubStr(L *LState, str string, repl string, matches []*pm.MatchData) string { |
| 222 | infoList := make([]replaceInfo, 0, len(matches)) |
no outgoing calls
no test coverage detected
searching dependent graphs…