You can edit almost every page by Creating an account and confirming your email.

Module:Text count

From EverybodyWiki Bios & Wiki

Usage

Counts the number of times an pattern appears in the arguments that get passed on to this module.

{{#invoke:Text count|main}}



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

This module "Text count" is from Wikipedia if otherwise notified