Module:OfcFunctions
Documentation for this module may be created at Module:OfcFunctions/doc
local p = {}
-- string parsing functions
function p.test()
return "hello, world!"
end
function p.trim(input)
return input:gsub("^%s+", ""):gsub("%s+$", "")
end
function p.split(input, delimiter)
if delimiter == nil then
delimiter = " "
end
local pattern = string.format("([^%s]+)", delimiter)
local result = {}
for substr in input:gmatch(pattern) do
result[#result + 1] = substr
end
return result
end
-- category functions
function p.splitToCategoryTags(input, delimiter)
local arr = p.split(input, delimiter);
local result = "";
for i = 1, #arr do
result = result .. string.format("[Category:%s]\n", p.trim(arr[i]))
end
return result;
end
return p