Jump to content

Module:String2

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by RexxS (talk | contribs) at 00:22, 14 December 2013 (create module to supply simple string case functions - upper, lower, sentence; intended for use in infoboxes). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

local p = {}

p.upper = function( frame )
	local s = mw.text.trim( frame.args[1] or "" )
	return string.upper( s )
end

p.lower = function( frame )
	local s = mw.text.trim( frame.args[1] or "" )
	return string.lower( s )
end

p.sentence = function (frame )
	local s =  mw.text.trim( frame.args[1] or "" )
	local strFirst = string.sub( s, 1, 1 )
	local strRest = string.sub( s, 2 )
	return string.upper( strFirst ) .. string.lower( strRest )
end

return p