MCPcopy Index your code
hub / github.com/yuin/gopher-lua / strGsubDoReplace

Function strGsubDoReplace

stringlib.go:203–219  ·  view source on GitHub ↗
(str string, info []replaceInfo)

Source from the content-addressed store, hash-verified

201}
202
203func 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
221func strGsubStr(L *LState, str string, repl string, matches []*pm.MatchData) string {
222 infoList := make([]replaceInfo, 0, len(matches))

Callers 3

strGsubStrFunction · 0.85
strGsubTableFunction · 0.85
strGsubFuncFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…