(L *LState, str string, repl *LTable, matches []*pm.MatchData)
| 245 | } |
| 246 | |
| 247 | func 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 | |
| 267 | func strGsubFunc(L *LState, str string, repl *LFunction, matches []*pm.MatchData) string { |
| 268 | infoList := make([]replaceInfo, 0, len(matches)) |
no test coverage detected
searching dependent graphs…