Difference between revisions of "Module:String"
Jump to navigation
Jump to search
>Dragons flight (replace with enwiki's version which is more mature) |
>SPage (WMF) (Undo revision 652101 (it's breaking {Str sub}} and {{git}}) by Dragons flight (talk)) |
||
Line 1: | Line 1: | ||
local p = {} | |||
function p.length( frame ) | |||
local arg1 = frame.args[1] | |||
return string.len( arg1 ) | |||
end | |||
function p.sub( frame ) | |||
local arg1 = frame.args[1] | |||
local arg2 = tonumber( frame.args[2] ) | |||
local arg3 = tonumber( frame.args[3] ) | |||
if arg2 and arg3 then | |||
local first = arg2 + 1 | |||
local last = arg2 + arg3 | |||
return string.sub( arg1, first, last ) | |||
local | |||
] | |||
local | |||
local | |||
if | |||
return | |||
else | else | ||
return "" | |||
return | |||
end | end | ||
end | end | ||
return | return p |
Revision as of 05:20, 26 February 2013
Documentation for this module may be created at Module:String/doc
local p = {}
function p.length( frame )
local arg1 = frame.args[1]
return string.len( arg1 )
end
function p.sub( frame )
local arg1 = frame.args[1]
local arg2 = tonumber( frame.args[2] )
local arg3 = tonumber( frame.args[3] )
if arg2 and arg3 then
local first = arg2 + 1
local last = arg2 + arg3
return string.sub( arg1, first, last )
else
return ""
end
end
return p