Commons:File description page regular expressions

From Wikimedia Commons, the free media repository
Jump to: navigation, search

This is a list of some regular expressions for localisation and general fixes for bots to do. Some of these are fairly trivial and should be combined with other tasks. Regexes marked as minor should not be run alone. If you have any regexes you use and would like to share, please add them below.

Everything is case-insensitive unless specified otherwise. The expressions should be executed from top to bottom. If any of these cause problems, please report it on the talk page. They're reasonably tested but no guarantees.

Localization/Internationalization[edit]

Headings[edit]

Task Find Replace Notes
"Summary" heading ^(\=+) *(?:summary|(?:Краткое[ _]+)?описание|Beschreibung\,[ _]+Quelle|Quelle|Beschreibung|वर्णन|sumario|descri(ption|pción|ção do arquivo)|achoimriú)( */ *(?:summary|(?:Краткое[ _]+)?описание|Beschreibung\,[ _]+Quelle|Quelle|Beschreibung|वर्णन|sumario|descri(ption|pción|ção do arquivo)|achoimriú))? *\:? *\1 $1 {{int:filedesc}} $1 [MultiLine]
"Licensing" heading ^(\=+) *(\[\[.*?\|)?(za(?: +d\'uso)?|Лицензирование|li[zcs]en[zcs](e|ing|ia)?(?:\s+information)?( */ *(za(?: +d\'uso)?|Лицензирование|li[zcs]en[zcs](e|ing|ia)?(?:\s+information)?))?|\{\{int:license\}\})(\]\])? *\:? *\1 $1 {{int:license-header}} $1 [MultiLine]
"Original upload log" heading ^(\=+) *(?:original upload ?(log|history)|\{\{int:wm\-license\-original\-upload\-log\}\}|file ?history|ursprüngliche bild-versionen) *\:? *\1 $1 {{original upload log}} $1 [MultiLine]
Remove duplicate headings ^ *(\=+) *(.*?) *\=+ *[\r\n]+\=+ *\2 *\=+ *$ $1 $2 $1 [MultiLine]; Run multiple times

Multilingual tags[edit]

Task Find Replace Notes
{{unknown}} (\|\s*(?:author|artist)\s*=\s*)(?:unknown?|\{\{\s*unknown\s*\}\}|\?+|unkown|αγνωστος|sconosciuto|ignoto|desconocido|inconnu|not known|desconhecido|unbekannt|неизвестно|Не известен|neznana|nieznany|непознат|okänd|sconossùo|未知|ukjent|onbekend|nich kennt|ലഭ്യമല്ല|непознат|نه‌ناسرا|descoñecido|不明|ignoto|óþekktur|tak diketahui|ismeretlen|nepoznat|לא ידוע|ûnbekend|tuntematon|نامعلوم|teadmata|nekonata|άγνωστος|ukendt|neznámý|desconegut|Неизвестен|ned bekannt|غير معروف|невідомий)\s*?\;?\.?\s*?(\||\}\}|\r|\n) $1{{unknown|author}}$2
{{own}} (part 1) (\|\s*source\s*=\s*)(?:own work)?\s*(?:-|;|</?br *[/\\]?>)?\s*(?:own(?: work(?: by uploader)?)?|(?:œuvre |travail )?personnel(?:le)?|self[- ]made|création perso|selbst fotografiert|obra pr[òo]pia|trabajo propr?io)\s*?(?:\(own work\))?\.? *(\||\}\}|\r|\n) $1{{own}}$2
{{own}} (part 2) (\|\s*source\s*=\s*)(?:\{\{[a-z]{2,3} *\|)? *(?:own(?: work(?: by uploader)?)?|travail personnel|self[- ]made|création perso|selbst fotografiert|obra pr[òo]pia|trabajo propr?io) *(?:\}\})? *(?:\{\{[a-z]{2,3} *\|)? *(?:\(?(?:own *work)\)?)? *(?:\}\})?(\||\}\}|\r|\n) (broken! Example: "{{Information | source = selbst fotografiert }}\newline" $1{{own}}$2
{{own}} (part 3) (\|\s*source\s*=\s*)(?:own[^a-z]*work|opera[^a-z]*propria|trabajo[^a-z]*propio|travail[^a-z]*personnel|eigenes[^a-z]*werk|eigen[^a-z]*werk|собственная[^a-z]*работа|投稿者自身による作品|自己的作品|praca[^a-z]*pw[łl]asna|Obra(?:[^a-z]*do)?[^a-z]*pr[]prio|Treball[^a-z]*propi|Собствена[^a-z]*творба|Vlastní[^a-z]*dílo|Eget[^a-z]*arbejde|Propra[^a-z]*verko|Norberak[^a-z]*egina|عمل[^a-z]*شخصي|اثر[^a-z]*شخصی|자작|अपना[^a-z]*काम|נוצר[^a-z]*על[^a-z]*ידי[^a-z]*מעלה[^a-z]*היצירה|Karya[^a-z]*sendiri|Vlastito[^a-z]*djelo[^a-z]*postavljača|Mano[^a-z]*darbas|A[^a-z]*feltöltő[^a-z]*saját[^a-z]*munkája|Karya[^a-z]*sendiri|Eget[^a-z]*verk|Oper[][^a-z]*proprie|Vlastné[^a-z]*dielo|Lastno[^a-z]*delo|Сопствено[^a-z]*дело|Oma[^a-z]*teos|Eget[^a-z]*arbete|Yükleyenin[^a-z]*kendi[^a-z]*çalışması|Власна[^a-z]*робота|Sariling[^a-z]*gawa|eie[^a-z]*werk|сопствено[^a-z]*дело|Eige[^a-z]*arbeid|პირადი[^a-z]*ნამუშევარი)\;?\.? *(\||\}\}|\r|\n) $1{{own}}$2
{{own}} (part 4) (\|\s*source\s*=\s*)(((?:\'\'+)?)([\"\']?)(?:selbst\W*erstellte?s?|selbst\W*gezeichnete?s?|self\W*made|eigene?s?)\W*(?:arbeit|aufnahme|(?:ph|f)oto(?:gra(?:ph|f)ie)?)?\.?\4\3) *(\||\}\}|\r|\n) $1{{own}} ({{original text|1=$2|nobold=1}})$5
{{self-photographed}} (\|\s*source\s*=\s*)(?:self[^a-z]*photographed|selbst[^a-z]*(?:aufgenommen|(?:f|ph)otogra(?:f|ph)iert?)|投稿者撮影|投稿者の撮影)\s*?\.? *(\||\}\}|\r|\n) $1{{self-photographed}}$2
{{anonymous}} (\|\s*author\s*=\s*)(?:anonym(?:e|ous)?|anonyymi|anoniem|an[oòóô]n[yi]mo?|ismeretlen|不明(匿名)|미상|ανώνυμος|аноним(?:ен|ный художник)|neznámy|nieznany|مجهول|Ананім|Anonymní|Ezezaguna|Anonüümne|אלמוני|អនាមិក|Anonimas|അജ്ഞാതം|Анонимный автор|佚名)\s*?\.?\;?\s*?(\||\}\}|\r|\n) $1{{anonymous}}$2
{{unknown photographer}} (\|\s*author\s*=\s*)(?:unknown\s*photographer|photographer\s*unknown)\s*?\;?\.?\s*?(\||\}\}|\r|\n) $1{{unknown photographer}}$2
{{private collection}} (\|\s*gallery\s*=\s*)private(?: collection)? *(\||\}\}|\r|\n) $1{{private collection}}$2
{{see below}} (\|\s*permission\s*=\s*)(?:see\s*below|див\.?\s*нижче|дивись\s*нижче)\s*?\;?\.?\s*?(\||\}\}|\r|\n) $1{{see below}}$2

{{original description page}}[edit]

Task Find Replace Notes
{{original description page}} I The original description page (?:is\/was|is|was) \[(?:https?:)?\/\/(?:www\.)?((?:[a-z\-]+\.)?wik[a-z]+(?:\-old)?)\.org\/w((?:\/shared)?)\/index\.php\?title\=(?:[a-z]+)(?:\:|%3A)([^\[\]\|}{]+?) +here(?:\]\.?|\.?\])(\s+All following user names refer to (?:\1(?:\.org)?\2|(?:wts|shared)\.oldwikivoyage)\.?)? {{original description page|$1$2|$3}}
{{original description page}} II This file was originally uploaded at ([a-z\-]+\.wik[a-z]+) as \[(?:https?:)?\/\/\1\.org\/wiki\/(?:[a-z]+)(?:\:|%3A)([\w\%\-\.\~\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=]+?)(?:| [^\]\n]*)\](?:\s*\,?\s*before it was transferr?ed to commons)?\.? {{original description page|$1|$2}}
{{original description page}} III (\=+\s*\{\{ *original[ _]+upload[ _]+log *\}\}\s*\=+\s*)(\{\{ *original[ _]+description[ _]+page *\|\s*([a-z\-]+\.w[a-z]+)\s*\|\s*[^}\|\[{]+\}\})\s*using\s*\[\[\:en\:WP\:FTCG\|FtCG\]\]\.? $1{{transferred from|$3||[[:en:WP:FTCG|FtCG]]}} $2

Technique translations[edit]

These mainly apply to paintings and other artistic works.

Task Find Replace Notes
Oil on canvas (\|\s*technique\s*=\s*)(?:\{\{ *(?:en|de) *\|)? *(?:oil[ -]on[ -]canvas|öl[ -]auf[ -]leinwand) *(?:\}\})?(\||\}\}|\r|\n) $1{{technique|oil|canvas}}$2
Oil on wood (\|\s*technique\s*=\s*)\{\{ *de *\|\s*öl[ -]auf[ -]holz *\}\}(\||\}\}|\r|\n) $1{{technique|oil|wood}}$2
Oil on oak (\|\s*technique\s*=\s*)\{\{ *de *\|\s*öl[ -]auf[ -]eichenholz *\}\}(\||\}\}|\r|\n) $1{{technique|oil|panel|wood=oak}}$2
Oil on panel (\|\s*technique\s*=\s*)(?:\{\{ *en *\|)? *oil[ -]on[ -]panel *(?:\}\})?(\||\}\}|\r|\n) $1{{technique|oil|panel}}$2
Watercolor (\|\s*technique\s*=\s*)\{\{ *de *\|\s*aquarell *\}\}(\||\}\}|\r|\n) $1{{technique|watercolor}}$2
Fresco (\|\s*technique\s*=\s*)\{\{ *de *\|\s*fresko *\}\}(\||\}\}|\r|\n) $1{{technique|fresco}}$2

{{Information}} fields[edit]

Task Find Replace Notes
"Description" cleanup (\|\s*description\s*=)\s*(?:\{\{ *description missing *\}\}|\s*description missing\s*?|(?:\{\{en *\|) *(?:'')?no original description(?:'')? *(?:\}\})|(?:'')?no original description(?:'')? *) *(\||\}\}|\r|\n) $1$2
"Permission" cleanup (\|\s*permission\s*=)\s*((?:\'\')?)(?:-|下記を参照|see(?: licens(?:e|ing|e +section))?(?: below)?|yes|oui)\s*?\,?\.?;?\s*?\2\s*?(\||\}\}|\r|\n) $1$3
"Other versions" cleanup (\|\s*other[_ ]versions\s*=)\s*(?:<i>)?(?:-|no|none?(?: known)?|nein|yes|keine|\-+)\.?(?:</i>)? *(\||\}\}|\r|\n) $1$2

Dates[edit]

Most plausible years[edit]

Most digital photos are dated after 2000. So the most plausible year is (200[0-9]|201[0-9]). For example 19082006 gets translated into 2006-08-19.

Task Find Replace Notes
Conversion (yyyy[ -/.]mm[ -/.]dd) (\|\s*date\s*=\s*)(?:created|made|taken)? *(200[0-9]|201[0-9])(-| |/|\.|)(0[1-9]|1[0-2])\3(1[3-9]|2[0-9]|3[01])(\||\}\}|\r|\n) $1$2-$4-$5$6
Conversion (yyyy[ -/.]dd[ -/.]mm) (\|\s*date\s*=\s*)(?:created|made|taken)? *(200[0-9]|201[0-9])(-| |/|\.|)(1[3-9]|2[0-9]|3[01])\3(0[1-9]|1[0-2])(\||\}\}|\r|\n) $1$2-$5-$4$6
Conversion (mm[ -/.]dd[ -/.]yyyy) (\|\s*date\s*=\s*)(?:created|made|taken)? *(0[1-9]|1[0-2])(-| |/|\.|)(1[3-9]|2[0-9]|3[01])\3(200[0-9]|201[0-9])(\||\}\}|\r|\n) $1$5-$2-$4$6
Conversion (dd[ -/.]mm[ -/.]yyyy) (\|\s*date\s*=\s*)(?:created|made|taken)? *(1[3-9]|2[0-9]|3[01])(-| |/|\.|)(0[1-9]|1[0-2])\3(200[0-9]|201[0-9])(\||\}\}|\r|\n) $1$5-$4-$2$6

Other plausible years[edit]

Try those after applying the above! For example 19781706 gets translated into 1978-06-17.

Task Find Replace Notes
Conversion (yyyy[ -/.]mm[ -/.]dd) (\|\s*date\s*=\s*)(?:created|made|taken)? *(1[89][0-9]{2})(-| |/|\.|)(0[1-9]|1[0-2])\3(1[3-9]|2[0-9]|3[01])(\||\}\}|\r|\n) $1$2-$4-$5$6
Conversion (yyyy[ -/.]dd[ -/.]mm) (\|\s*date\s*=\s*)(?:created|made|taken)? *(1[89][0-9]{2})(-| |/|\.|)(1[3-9]|2[0-9]|3[01])\3(0[1-9]|1[0-2])(\||\}\}|\r|\n) $1$2-$5-$4$6
Conversion (mm[ -/.]dd[ -/.]yyyy) (\|\s*date\s*=\s*)(?:created|made|taken)? *(0[1-9]|1[0-2])(-| |/|\.|)(1[3-9]|2[0-9]|3[01])\3(1[89][0-9]{2})(\||\}\}|\r|\n) $1$5-$2-$4$6
Conversion (dd[ -/.]mm[ -/.]yyyy) (\|\s*date\s*=\s*)(?:created|made|taken)? *(1[3-9]|2[0-9]|3[01])(-| |/|\.|)(0[1-9]|1[0-2])\3(1[89][0-9]{2})(\||\}\}|\r|\n) $1$5-$4-$2$6
Task Find Replace Notes
Conversion ({{date|yyyy|mm|dd}}) (\|\s*date\s*=\s*)(?:created|made|taken)? *\{\{date\|([0-9]{4})\|(0[1-9]|1[012])\|(0?[1-9]|1[0-9]|2[0-9]|3[01])\}\}(\||\}\}|\r|\n) $1$2-$3-$4$5 {{date}} function is built-in
Unknown date (\|\s*(?:date|year)\s*=\s*)(?:unknown?(?:\s*date)?|\?|unbekannte?s?(\s*datum)?) $1{{unknown|date}}
{{other date|century}} (\|\s*(?:date|year)\s*=\s*)(\d\d?)(?:st|nd|rd|th) *century *(\||\}\}|\r|\n) $1{{other date|century|$2}}$3
{{other date|~}} (\|\s*(?:date|year)\s*=\s*)(?:cir)?ca?\.? *(\d{4}) *(\||\}\}|\r|\n) $1{{other date|~|$2}}$3
{{other date|?}} (\|\s*(?:date|year)\s*=\s*)(?:unknown|\?+)\.? *(\||\}\}|\r|\n) $1{{other date|?}}$2
{{original upload date}} (original upload date) (\{\{original upload date\|\d{4}\-\d{2}\-\d{2}\}\})\s*(?:\(original\s*upload\s*date\)|\(\s*first\s*version\s*\);?\s*\{\{original upload date\|\d{4}\-\d{2}\-\d{2}\}\}\s*\(\s*last\s*version\s*\)) $1
{{original upload date}} & {{according to EXIF data}} (\|\s*date\s*=\s*)(?:\{\{date\|\s*(\d+)\s*\|\s*(\d+)\s*\|\s*(\d+)\s*\}\}|(\d{4})\-(\d{2})\-(\d{2}))\s*\(\s*(original upload date|according to EXIF data)\s*\)\s*?(\||\}\}|\r|\n) $1{{$8|$2$5-$3$6-$4$7}}$9
{{original upload date}} I (\|\s*date\s*=\s*)\{\{\s*date\s*\|\s*(\d+)\s*\|\s*(\d+)\s*\|\s*(\d+)\s*\}\}\s*\(\s*first\s*version\s*\)\;?\s*\{\{\s*date\s*\|\s*\d+\s*\|\s*\d+\s*\|\s*\d+\s*\}\}\s*\(\s*last\s*version\s*\) $1{{original upload date|$2-$3-$4}}
{{original upload date}} II (\|\s*date\s*=\s*)(\d{4})\-(\d{2})\-(\d{2})\s*\(\s*first\s*version\s*\)\;?\s*(\d{4})\-(\d{2})\-(\d{2})\s*\(\s*last\s*version\s*\) $1{{original upload date|$2-$3-$4}}
{{original upload date}} III (\|\s*date\s*=\s*\(?\s*)(?:Uploaded\s*on\s*Commons\s*at\s*[\d\-]*\s*[\d:]*\s*\(?UTC\)?\s*\/?\s*)?Original(?:ly)?\s*uploaded\s*at\s*([\d\-]*)\s*[\d:]* $1{{original upload date|$2}}
{{other date|s|}} (\|\s*date\s*=\s*)(\d{1,3}0)\s*s $1{{other date|s|$2}}
{{other date|after|}} (\|\s*date\s*=\s*)(?:after|post|بعد|desprès|po|nach|efter|μετά από|después de|pärast|پس از|après|despois do|לאחר|nakon|dopo il|по|na|após|după|после)\s*(\d{4}) $1{{other date|after|$2}}
{{other date|before|}} (\|\s*date\s*=\s*)(?:before|vor|pre|до|vör|voor|prior to|ante|antes de|قبل|Преди|abans|před|før|πριν από|enne|پیش از|ennen|avant|antes do|לפני|prije|prima del|пред|przed|înainte de|ранее|pred|före)[\s\-]*(\d{4}) $1{{other date|before|$2}}
{{other date|or|}} (\|\s*date\s*=\s*)(\d{4})\s*(?:or|أو|o|nebo|eller|oder|ή|ó|või|یا|tai|ou|או|vagy|または|или|അഥവാ|of|lub|ou|sau|или|ali|หรือ|)\s*?(\d{4}) $1{{other date|or|$2|$3}}
{{other date|between|}} (\|\s*date\s*=\s*)(?:sometime\s*)?(?:between)\s*(\d{4})\s*(?:and|\-)?\s*?(\d{4}) $1{{other date|between|$2|$3}}
{{other date|spring|}} (\|\s*date\s*=\s*)(?:primavera(?:\s*de)?|jaro|forår|frühling|spring|printempo|Kevät|printemps|пролет|Vörjohr|früh[ \-]?jahr|voorjaar|wiosna|primăvara(?:\s*lui)?|весна|pomlad|våren|spring)\s*(\d{4}) $1{{other date|spring|$2}}
{{other date|summer|}} (\|\s*date\s*=\s*)(?:estiu|léto|somero|verano|Kesä|été|verán|estate|лето|zomer|lato|verão(?:\s*de)?|vara(?:\s*lui)?|poletje|sommaren|sommer|summer)\s*(\d{4}) $1{{other date|summer|$2}}
{{other date|fall|}} (\|\s*date\s*=\s*)(?:fall|autumn|tardor|podzim|Efterår|Herbst|aŭtuno|otoño|Syksy|outono(?:\s*de)?automne|outono|autunno|есен|Harvst|herfst|jesień|toamna(?:\s*lui)?|осень|jesen|hösten)\s*(\d{4}) $1{{other date|fall|$2}}
{{other date|winter|}} (\|\s*date\s*=\s*)(?:winter|hivern|zima|Vinter|vintro|invierno|Talvi|hiver|inverno(?:\s*de)?|зима|iarna(?:\s*lui)?|зима|zima|vintern)\s*(\d{4}) $1{{other date|winter|$2}}
{{other date|circa||}} (\|\s*date\s*=\s*)(?:[zc]ir[kc]a|ungefähr|about|around|vers|حوالي|cca|etwa|περ\.?|cerca\s*de|حدود|noin|cara a|oko|około|около|c[\:\. ]?a?[\:\. ]?)\s*(\d{3,4})(?:\s*\-\s*(?:[zc]ir[kc]a|ungefähr|about|around|vers|حوالي|cca|etwa|περ\.?|cerca\s*de|حدود|noin|cara a|oko|około|около|c[\:\. ]?a?[\:\. ]?)?\s*(\d{3,4}))? $1{{other date|circa|$2|$3}}
empty argument fix (\{\{other date\|circa\|\d+)\|\}\} $1}}
{{other date|circa|}} (\|\s*date\s*=\s*)(?:[zc]ir[kc]a|ungefähr|about|around|vers|حوالي|cca|etwa|περ\.?|cerca\s*de|حدود|noin|cara a|oko|około|около|c[\:\. ]?a?[\:\. ]?)\s*(\d{3,4}) $1{{other date|circa|$2}}
(from metadata) (\|\s*date\s*=\s*)\{\{\s*ISOdate\s*\|\s*([\d\-]+)\s*\}\}\s*\(\s*from\s*metadata\s*\) $1{{according to EXIF|$2}}

Junk cleanup[edit]

Task Find Replace Notes
{{ImageUpload}} removal <!--\s*\{\{ImageUpload\|(full|basic)\}\}\s*-->\s*\n? [Minor]
Uncategorized comment  *<!-- *Remove this line once you have added categories *--> * [Minor]; Usually left behind after categorizing
"Categories" comment  *<!-- *categories *--> *\n? [Minor]
"move approved by" (?:move approved by: *\[\[:?User:[^\]\[{}]*\]\]\.?)?((?:.|\n)*?)(?:This image was moved from *\[\[:?(?:File|image):?[^\]\[{}]*\]\]\.?)? $1
Useless templates (if they take no parameters) \{\{\s*(?:Ship|Art\.|bots|football[ _]+kit|template[ _]+other|s|tl|tlxs|template|template[ _]+link|temp|tls|tlx|tl1|tlp|tlsx|tlsp|mbox|tmbox(?:\/core)?|lan|jULIANDAY|file[ _]+title|nowrap|plural|time[ _]+ago|time[ _]+ago\/core|toolbar|red|green|sp|other date|max|max\/2|str[ _]+left|str[ _]+right|music|date|cite[ _]+book|citation\/core|citation\/make[ _]+link|citation\/identifier|citation|cite|cite[ _]+book|citation\/authors|citation\/make[ _]+link|cite[ _]+journal|cite[ _]+patent|cite[ _]+web|hide in print|only in print|parmPart|error|crediti|fontcolor|transclude|trim|navbox|navbar|section[ _]+link|yesno|center|unused||infobox\/row)\s*\}\}
Useless full URL \{\{\s*PermissionOTRS\s*\|\s*(?:https?:)?\/\/ticket\.wikimedia\.org\/otrs\/index\.pl\?Action\s*\=\s*AgentTicketZoom&(?:amp;)?TicketNumber\=(\d+)\s*\}\} {{PermissionOTRS|id=$1}}
Unnecessary __NOTOC__ __ *NOTOC *__ [Case sensitive] [Minor]; Common.css prevents file pages from showing TOCs
Remove empty lang templates \{\{en *(?:\|\s*1=)? *\}\} *(\||\}\}|\r|\n) $1 Ignores those followed by text (incorrect usage but still indicates the language)

Links[edit]

Task Find Replace Notes
External to interwiki (part 1) \[https?://([a-z0-9\-]{2,3})\.(?:(w)ikipedia|(wikt)ionary|wiki(n)ews|wiki(b)ooks|wiki(q)uote|wiki(s)ource|wiki(v)ersity|wiki(voy)age)\.(?:com|net|org)/wiki/([^\]\[{|}\s"]*) +([^\n\]]+)\] [[$2$3$4$5$6$7$8$9:$1:$10|$11]] Make sure not to touch credit lines which require a link to the file page. (Effectively a self-link which results in bold text after this regex)
External to interwiki (part 2) \[https?://(?:(m)eta|(incubator)|(quality))\.wikimedia\.(?:com|net|org)/wiki/([^\]\[{|}\s"]*) +([^\n\]]+)\] [[$1$2$3:$4|$5]] See above
External to wikilink (local) \[https?://commons\.wikimedia\.(?:com|net|org)/wiki/([^\]\[{|}\s"]*) +([^\n\]]+)\] [[:$1|$2]] See above

Categories[edit]

These are mainly to improve machine-readability when performing other category work.

Task Find Replace Notes
Normalize categories  *\[\[category *: *([^]]*?) *(\|[^]]*)?\]\] * [[Category:$1$2]] Run this before the other category fixes
Remove empty [[Category:]] \[\[category: *\]\](?:\n( *\[\[category:))? $1
One category per line \[\[category:([^]]+)\]\] *\[\[category:([^]]+)\]\] [[Category:$1]]\n[[Category:$2]] Run multiple times
Remove duplicates (\[\[category:)([^]]+\]\])(.*?)\1\2\n? $1$2$3 Run multiple times
Remove blank lines between categories (\[\[category:[^]]+\]\]\n)\n+(\[\[category:) $1$2 [Minor]

Formatting[edit]

Task Find Replace Notes
Delete surplus lines \n{3,} \n\n [Minor]
Fix incorrect line break syntax </?br( )?(/)?\\?> <br$1$2> This fixes only incorrect syntax (so <br>, <br/>, and <br /> are preserved)
Remove {{}}, [[]], <gallery></gallery>, etc. (\{\{\}\}|\[\[\]\]|<gallery></gallery>|\[\[:?File *: *\]\])
prettytable → wikitable \b(class\s*=\s*)("[^"]*)?prettytable([^"]*")? $1$2wikitable$3

See also[edit]