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

Function strGsubStr

stringlib.go:221–245  ·  view source on GitHub ↗
(L *LState, str string, repl string, matches []*pm.MatchData)

Source from the content-addressed store, hash-verified

219}
220
221func strGsubStr(L *LState, str string, repl string, matches []*pm.MatchData) string {
222 infoList := make([]replaceInfo, 0, len(matches))
223 for _, match := range matches {
224 start, end := match.Capture(0), match.Capture(1)
225 sc := newFlagScanner('%', "", "", repl)
226 for c, eos := sc.Next(); !eos; c, eos = sc.Next() {
227 if !sc.ChangeFlag {
228 if sc.HasFlag {
229 if c >= '0' && c <= '9' {
230 sc.AppendString(capturedString(L, match, str, 2*(int(c)-48)))
231 } else {
232 sc.AppendChar('%')
233 sc.AppendChar(c)
234 }
235 sc.HasFlag = false
236 } else {
237 sc.AppendChar(c)
238 }
239 }
240 }
241 infoList = append(infoList, replaceInfo{[]int{start, end}, sc.String()})
242 }
243
244 return strGsubDoReplace(str, infoList)
245}
246
247func strGsubTable(L *LState, str string, repl *LTable, matches []*pm.MatchData) string {
248 infoList := make([]replaceInfo, 0, len(matches))

Callers 1

strGsubFunction · 0.85

Calls 8

newFlagScannerFunction · 0.85
capturedStringFunction · 0.85
strGsubDoReplaceFunction · 0.85
CaptureMethod · 0.80
AppendStringMethod · 0.80
AppendCharMethod · 0.80
StringMethod · 0.65
NextMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…