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

Module:Navseasoncats/var season

From EverybodyWiki Bios & Wiki

Documentation for this module may be created at Module:Navseasoncats/var season/doc

local p = {}

function p.var_season(frame)
	--Extracts e.g. 2015–16 or 2015 out of a string
	local arg, pagename, titleyear = nil
	if frame.args[1] then arg = mw.text.trim(frame.args[1]) end
	if arg and arg ~= '' then
		pagename = arg
		titleyear = frame:expandTemplate{ title = 'Title year', args = { page = pagename } }
	else
		pagename = mw.title.getCurrentTitle().text
		titleyear = frame:expandTemplate{ title = 'Title year', args = { pagename } }
	end

	local strleft4 = string.match(pagename, '^[%d%D]?[%d%D]?[%d%D]?[%d%D]?')
	if titleyear == strleft4 then
		local firstword = frame:expandTemplate{ title = 'First word', args = { pagename } }
		return firstword
	else
		local pos = mw.ustring.find( pagename, titleyear, 1, true ) or 0
		local posm1 = pos - 1
		local strright = frame:expandTemplate{ title = 'Str right', args = { pagename, posm1 } }
		local firstword = frame:expandTemplate{ title = 'First word', args = { strright } }
		return firstword
	end
end

return p