Module:Template redirect regex: Difference between revisions
From Neodyland Wiki
More actions
Create module to return a table of regular expressions, sorted by descending popularity, for all redirects to a given template as of a certain date |
m 14 revisions imported |
||
| (13 intermediate revisions by 6 users not shown) | |||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
--returns a table of regular expressions, sorted by descending popularity, for all redirects to | --returns a table of regular expressions, sorted by descending popularity, for a parent template and all redirects to it as of a certain date, or nil | ||
--regex for the 1st pipe and surrounding whitespace are purposefully omitted to give the calling modules more flexibility | |||
function p.main( template ) | function p.main( template ) | ||
| Line 7: | Line 8: | ||
local tCanonical_templates = { | local tCanonical_templates = { | ||
['Category redirect'] = { | ['Category redirect'] = { | ||
-- | -- Commons June 2024: 12 | ||
'{{ *[Cc]ate?g?o?r?y?[ _]*[rR]edirect', | -- https://commons.wikimedia.org/wiki/Special:WhatLinksHere?target=Template%3ACategory+redirect&namespace=&hidetrans=1&hidelinks=1 | ||
'{{ *[Cc] | '{{ *[Cc]ate?g?o?r?y?[ _\\-]*[rR]edirect', | ||
'{{ *[Cc]at[ _]*[rR] | '{{ *[Cc]at[ \\_]*[rR]edir', -- | ||
'{{ *[ | '{{ *[Cc]at[ \\_\\-]*[rR]ed', -- | ||
'{{ *[ | '{{ *[Rr]edirect[ \\_]category', | ||
'{{ *[Rr]edirect[ _]cat', | |||
'{{ *[Ss]ee[ \\_]*cat', | |||
'{{ *[Cc]atr', -- | |||
'{{ *[Mm]onotypic[ \\_]+taxon[ \\_]+category[ \\_]+redirect', | |||
'{{ *[Ii]nvalid[ \\_]+taxon[ \\_]+category[ \\_]+redirect', | |||
}, | }, | ||
} | } | ||
Latest revision as of 16:37, 12 August 2026
This documentation is transcluded from Module:Template redirect regex/doc.
local p = {}
--returns a table of regular expressions, sorted by descending popularity, for a parent template and all redirects to it as of a certain date, or nil
--regex for the 1st pipe and surrounding whitespace are purposefully omitted to give the calling modules more flexibility
function p.main( template )
--expand the following table as-needed, following the same format
local tCanonical_templates = {
['Category redirect'] = {
-- Commons June 2024: 12
-- https://commons.wikimedia.org/wiki/Special:WhatLinksHere?target=Template%3ACategory+redirect&namespace=&hidetrans=1&hidelinks=1
'{{ *[Cc]ate?g?o?r?y?[ _\\-]*[rR]edirect',
'{{ *[Cc]at[ \\_]*[rR]edir', --
'{{ *[Cc]at[ \\_\\-]*[rR]ed', --
'{{ *[Rr]edirect[ \\_]category',
'{{ *[Rr]edirect[ _]cat',
'{{ *[Ss]ee[ \\_]*cat',
'{{ *[Cc]atr', --
'{{ *[Mm]onotypic[ \\_]+taxon[ \\_]+category[ \\_]+redirect',
'{{ *[Ii]nvalid[ \\_]+taxon[ \\_]+category[ \\_]+redirect',
},
}
return tCanonical_templates[template] or nil
end
return p