local p = local getArgs = require('Module:Arguments').getArgs
--args: 1 - page to search, 2 - match pattern
local function allcases(s) return s:gsub('([%?%^%$%(%)%%%.%[%]%*%+%-])', '%%%1') :gsub('%a', function(letter) return '['..letter:upper..letter:lower..']' end) :gsub('%[([^%[%]]+)%]', '%1')end
function p._match(args) local page = mw.title.new(args["1"]) if not page then --bad title return "" end local redirectTarget = page.redirectTarget if redirectTarget then page = mw.title.new(redirectTarget.prefixedText) end local content = page:getContent if not content then --page does not exist return "" end local pattern = args["2"] or "" return mw.ustring.match(content, pattern)end
function p.match(frame) local args = getArgs(frame) return p._match(args)end
return p