Jump to content

Module:TableTools: Difference between revisions

escape prefix and suffix strings in affixNums so that magic characters are interpreted literally
m>Mr. Stradivarius
(add p.numData function)
m>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
Cookies help us deliver our services. By using our services, you agree to our use of cookies.