Module:Text count

local z = {}

function z.main(frame) local config = frame.args local errors = {} if not config.text then table.insert(errors, "no text argument. Please provide the text that you wish to count strings in.") end if not config.pattern then table.insert(errors, "no pattern argument. Please provide the string you wish to search for.") end if table.maxn(errors) == 0 then local temp, count = mw.ustring.gsub(config.text, config.pattern, "%0") return count else return table.concat(errors, " ") end end

return z