Module:String2: Difference between revisions
From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
Content added Content deleted
(update from sandbox -- fix for when the text passed is an html list) |
(function stripZeros) |
||
Line 83: | Line 83: | ||
end |
end |
||
end |
end |
||
-- stripZeros finds the first number and strips leading zeros (apart from units) |
|||
-- e.g "0940" -> "940"; "Year: 0023" -> "Year: 23"; "00.12" -> "0.12" |
|||
p.stripZeros = function(frame) |
|||
local s = mw.text.trim(frame.args[1] or "") |
|||
n = tonumber( string.match( s, "%d+" ) ) or "" |
|||
return string.gsub( s, "%d+", n, 1 ) |
|||
end |
|||
return p |
return p |