Module:string utilities
Appearance
Documentation for this module may be created at Module:string utilities/doc
local module_name = "string_utilities"
local export = {}
local format_escapes = {
["op"] = "{",
["cl"] = "}",
}
function export.format(str, tbl)
return (string.gsub(str, "{(\\?)((\\?)[^{}]*)}", function (p1, name, p2)
if #p1 + #p2 == 1 then
return format_escapes[name] or error(module_name .. ".format: unrecognized escape sequence '{\\" .. name .. "}'")
else
return tbl[name] or error(module_name .. ".format: '" .. name .. "' not found in table")
end
end))
end
return export