Anonymous user
Module:TableTools: Difference between revisions
From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
escape prefix and suffix strings in affixNums so that magic characters are interpreted literally
(add p.numData function) |
(escape prefix and suffix strings in affixNums so that magic characters are interpreted literally) |
||
Line 133:
checkType('affixNums', 2, prefix, '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 ''
suffix = suffix or ''
prefix = cleanPattern(prefix)
suffix = cleanPattern(suffix)
local pattern = '^' .. prefix .. '([1-9]%d*)' .. suffix .. '$'
local nums = {}
for k, v in pairs(t) do
|