မဝ်ဂျူ:ugly hacks
မံက်ပြာကတ်
Documentation for this module may be created at မဝ်ဂျူ:ugly hacks/doc
local export = {}
function export.explode(frame)
local args = frame.args
local wanted_index, i = tonumber(args[3]), 1
for item in require("Module:string utilities").gsplit(args[1], args[2], true) do
if i == wanted_index then
return item
end
i = i + 1
end
return ""
end
function export.substr(frame)
local args = frame.args
return require("Module:string utilities").sub(args[1] or "", tonumber(args[2]) or 1, tonumber(args[3]) or -1)
end
function export.find(frame)
local args = frame.args
return require("Module:string utilities").find(args[1] or "", args[2] or "", 1, true) or ""
end
function export.find_pattern(frame)
local args = frame.args
return require("Module:string utilities").find(args[1] or "", args[2] or "", 1, false) or ""
end
function export.replace(frame)
local args = frame.args
return (require("Module:string utilities").gsub(args[1] or "", args[2] or "", args[3] or ""))
end
function export.match(frame)
local args = frame.args
return (require("Module:string utilities").match(args[1] or "", args[2] or ""))
end
function export.is_valid_page_name(frame)
return require("Module:pages").is_valid_page_name(frame.args[1]) and "valid" or ""
end
local mt = {}
function mt:__index(k)
local track = require("Module:debug/track")
local parent = mw.getCurrentFrame():getParent()
track("ugly hacks/" .. k)
if parent then
track("ugly hacks/" .. k .. "/from " .. parent:getTitle())
end
return export[k]
end
return setmetatable({}, mt)