Module:StringUtil: Difference between revisions
Appearance
Created page with "local p = {} -- Removes "EF" prefix and "+" suffix, e.g., EF3+ → 3 function p.stripEFPlus(frame) local input = frame.args[1] or "" return input:gsub("^EF", ""):gsub("%+$", "") end -- Removes "EF" prefix only, e.g., EF3+ → 3+ function p.stripEFPrefix(frame) local input = frame.args[1] or "" return input:gsub("^EF", "") end -- Adds "+" if the input ends in "+", else returns empty function p.plusSuffix(frame) local input = frame.args[1] or "" if input:match("%+..." |
No edit summary Tags: Mobile edit Mobile web edit |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
function p.stripEFPlus(frame) | function p.stripEFPlus(frame) | ||
local input = frame.args[1] or "" | local input = frame.args[1] or "" | ||
return input:gsub("^EF", ""):gsub(" | return input:gsub("^EF", ""):gsub("P$", "") | ||
end | end | ||
Line 13: | Line 12: | ||
end | end | ||
function p.plusSuffix(frame) | function p.plusSuffix(frame) | ||
local input = frame.args[1] or "" | local input = frame.args[1] or "" | ||
if input:match(" | if input:match("P$") then | ||
return "+" | return "+" | ||
else | else |
Latest revision as of 11:19, 2 May 2025
Documentation for this module may be created at Module:StringUtil/doc
local p = {}
function p.stripEFPlus(frame)
local input = frame.args[1] or ""
return input:gsub("^EF", ""):gsub("P$", "")
end
-- Removes "EF" prefix only, e.g., EF3+ → 3+
function p.stripEFPrefix(frame)
local input = frame.args[1] or ""
return input:gsub("^EF", "")
end
function p.plusSuffix(frame)
local input = frame.args[1] or ""
if input:match("P$") then
return "+"
else
return ""
end
end
return p