Documentation for this module may be created at Module:Replace/doc
return {
repl = function(frame)
local args = frame.args
local argc = 1
local function nextarg() argc = argc + 1 return args[argc - 1] end
local input_data = args["in"] or nextarg()
if not input_data then error "No input data (parameter 'in' or #1)" end
local named = not not args.match1
local repl_count = 0
while true do
repl_count = repl_count + 1
local matcher = named and args["match"..repl_count] or nextarg()
local replacement = named and args["repl"..repl_count] or nextarg()
if not (matcher and replacement) then
error("Incomplete match/replacement pair #" .. repl_count)
end
input_data = input_data:gsub(matcher, replacement)
end
return input_data
end
}