Difference between revisions of "Module:TableTools"
Jump to navigation
Jump to search
p.affixNums: move the pattern-generating code out of the loop
>Mr. Stradivarius (use a hack to handle NaN values) |
>Mr. Stradivarius (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, | local num = mw.ustring.match(k, pattern) | ||
if num then | if num then | ||
nums[#nums + 1] = tonumber(num) | nums[#nums + 1] = tonumber(num) |