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

Function strGsubTable

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

Source from the content-addressed store, hash-verified

245}
246
247func strGsubTable(L *LState, str string, repl *LTable, matches []*pm.MatchData) string {
248 infoList := make([]replaceInfo, 0, len(matches))
249 for _, match := range matches {
250 idx := 0
251 if match.CaptureLength() > 2 { // has captures
252 idx = 2
253 }
254 var value LValue
255 if match.IsPosCapture(idx) {
256 value = L.GetTable(repl, LNumber(match.Capture(idx)))
257 } else {
258 value = L.GetField(repl, str[match.Capture(idx):match.Capture(idx+1)])
259 }
260 if !LVIsFalse(value) {
261 infoList = append(infoList, replaceInfo{[]int{match.Capture(0), match.Capture(1)}, LVAsString(value)})
262 }
263 }
264 return strGsubDoReplace(str, infoList)
265}
266
267func strGsubFunc(L *LState, str string, repl *LFunction, matches []*pm.MatchData) string {
268 infoList := make([]replaceInfo, 0, len(matches))

Callers 1

strGsubFunction · 0.85

Calls 9

LNumberTypeAlias · 0.85
LVIsFalseFunction · 0.85
LVAsStringFunction · 0.85
strGsubDoReplaceFunction · 0.85
CaptureLengthMethod · 0.80
IsPosCaptureMethod · 0.80
CaptureMethod · 0.80
GetTableMethod · 0.45
GetFieldMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…