Difference between revisions of "Module:TableTools"

Jump to navigation Jump to search
escape prefix and suffix strings in affixNums so that magic characters are interpreted literally
en>Mr. Stradivarius
(add p.numData function)
en>Mr. Stradivarius
(escape prefix and suffix strings in affixNums so that magic characters are interpreted literally)
Line 133: Line 133:
checkType('affixNums', 2, prefix, 'string', true)
checkType('affixNums', 2, prefix, 'string', true)
checkType('affixNums', 3, suffix, 'string', true)
checkType('affixNums', 3, suffix, 'string', true)
local function cleanPattern(s)
-- Cleans a pattern so that the magic characters ()%.[]*+-?^$ are interpreted literally.
s = s:gsub('([()%%.%[%]*+-?^$])', '%%%1')
return s
end
prefix = prefix or ''
prefix = prefix or ''
suffix = suffix or ''
suffix = suffix or ''
prefix = cleanPattern(prefix)
suffix = cleanPattern(suffix)
local pattern = '^' .. prefix .. '([1-9]%d*)' .. suffix .. '$'
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
Anonymous user

Navigation menu