Module:TableTools: Difference between revisions

From Tardis Wiki, the free Doctor Who reference
p.affixNums: move the pattern-generating code out of the loop
(use a hack to handle NaN values)
(p.affixNums: move the pattern-generating code out of the loop)
Line 135: Line 135:
prefix = prefix or ''
prefix = prefix or ''
suffix = suffix or ''
suffix = suffix or ''
local pattern = '^' .. prefix .. '([1-9]%d*)' .. suffix .. '$'
local nums = {}
local nums = {}
for k, v in pairs(t) do
for k, v in pairs(t) do
if type(k) == 'string' then
if type(k) == 'string' then
local num = mw.ustring.match(k, '^' .. prefix .. '([1-9]%d*)' .. suffix .. '$')
local num = mw.ustring.match(k, pattern)
if num then
if num then
nums[#nums + 1] = tonumber(num)
nums[#nums + 1] = tonumber(num)
Cookies help us deliver our services. By using our services, you agree to our use of cookies.