Home
Random
Log in
Settings
About OtherX
Disclaimers
Search
Editing
Module:Addcommas
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
--[[ {{Helper module|name=Addcommas |fname1=_add(arg) |ftype1=Number |fuse1=Formats the number arg with commas |fname2=_strip(arg) |ftype2=Number |fuse2=Removes all commas from arg }} --]] -- <nowiki> -- -- Implements {{Addcommas}} -- local p = {} -- -- main function -- keep public so it can be used in other modules -- function p._add( arg ) local lang = mw.language.getContentLanguage() local z = tostring( arg ) local y = mw.text.split( z, '[%-β]' ) local x -- strip any existing commas z = z:gsub( ',', '' ) -- handle ranges as separate numbers -- required by [[Module:Exchange]] (p._table) if y[1] ~= '' and y[2] then y[1] = tonumber( y[1] ) y[2] = tonumber( y[2] ) x = lang:formatNum( y[1] ) .. 'β' .. lang:formatNum( y[2] ) else x = lang:formatNum( tonumber( z ) ) end return x end -- -- strips any existing commas in the input -- function p._strip( str ) str = tostring( str ) return str:gsub( ',', '' ) end function p.commas ( frame ) local str = frame:getParent().args[1] return p._add( str ) end return p
Summary:
Please note that all contributions to OtherX may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
OtherX:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Documentation
(
edit
)
Template:Helper module
(
edit
)
Module:Addcommas
(
edit
)
Module:Addcommas/doc
(
edit
)
Module:Array
(
edit
)
Module:DPLlua
(
edit
)
Module:DependencyList
(
edit
)
Module:Documentation
(
edit
)
Module:Helper module
(
edit
)
Module:Mw.html extension
(
edit
)
Module:Paramtest
(
edit
)
Module:Tooltip
(
edit
)
Module:Yesno
(
edit
)
This page is a member of a hidden category:
Category:Pages with broken file links