Anonymous user
Module:Resolve category redirect: Difference between revisions
Combine similar & most popular regex[1] & [2]
Richardpruen (talk | contribs) m (1 revision imported) |
imported>Tom.Reding (Combine similar & most popular regex[1] & [2]) |
||
Line 2: | Line 2: | ||
--Returns the target of {{Category redirect}}, if it exists, else returns the original cat. | --Returns the target of {{Category redirect}}, if it exists, else returns the original cat. | ||
function rtarget( cat ) | function rtarget( cat ) | ||
local catcontent = mw.title.new( cat or '', 'Category' ):getContent() | local catcontent = mw.title.new( cat or '', 'Category' ):getContent() | ||
if string.match( catcontent or '', '{{ *[Cc]at' ) then | if string.match( catcontent or '', '{{ *[Cc]at' ) then | ||
local regex = { | local regex = { | ||
--the following 11 pages ( | --the following 11 pages (6 condensed) redirect to [[Template:Category redirect]], in descending order, as of 9/2022: | ||
'{{ *[Cc]ate?g?o?r?y?[ _]*[rR]edirect', --505+312+243+1 transclusions | |||
'{{ *[Cc]atr', --21 | |||
'{{ *[Cc]at[ _]*[rR]edir', --5+3 | |||
'{{ *[Cc]at[ _]*[rR]ed', --3+2 | |||
'{{ *[Cc]at[ _]*[mM]ove', --1 | |||
'{{ *[Cc]ategory[ _]*[mM]ove', --0 | |||
} | } | ||
for _, v in pairs (regex) do | for _, v in pairs (regex) do |