Jump to content

User:Tol/Regex

From Wikipedia, the free encyclopedia

This is a list of regexes for my convenience.

2017 Wikitext Editor

[edit]
All reference tags
<ref(?:.*?)<\/ref>
Curly quotes
[“”‘’]

Needs work

[edit]
References without a {{Cite *}} template
<ref>(?!{{(C|c)ite)
All {{Cite *}} templates
{{(C|c)ite(.*?)}}
Internal external links
\[https:\/\/en\.wikipedia\.org\/wiki\/(.*?) (.*?)\]
Fix reference punctuation
(\<ref(?:.*?)(?:\/\>|</ref>))([,.])?
$2$1
Add scope (for List of presidents of the United States)
! (?:(rowspan=[234] )\| )?\[\[Presidenc
! scope="row" $1| [[Presidenc

AWB1

[edit]
Superseded by TolBot Task 4

Setup:

Summary:

[[User:Tol/Regex#AWB1|AWB1]]: remove [[Template:Draft categories]] from mainspace article

Find and replace:

  • Regex
    Flags: s
  • From:
    \n\{\{(D|d)raft categories(\|1\=|\|)(.*?)\n\}\}
  • To:
    $3

AWB2

[edit]

Setup:

Summary:

[[User:Tol/Regex#AWB2|AWB2]]: use [[WP:IBI|plain image in infobox]] instead of thumbnail

Find and replace:

  • Regex
  • From:
    \n( *?)\|( *?)(image(?:_?\d)?|image_name|map_image|logo)( *?)\=[ \n]*?\[\[(?:File|Image)\:(.*?)\|thumb(?:\|(?:\d*?px)?)?\]\] (automatic, no intervention required)
    \n( *?)\|( *?)(image(?:_?\d)?|image_name|map_image|logo)( *?)\=[ \n]*?\[\[(?:File|Image)\:(.*?)\|thumb(?:.*?)\]\] (manual, does most of the work but captions must still be manually checked)
  • To:
    \n$1|$2$3$4= $5

AWB3

[edit]

Setup:

Summary:

[[User:Tol/Regex#AWB3|AWB3]]: add [[Template:Taxonbar]]

Find and replace:

  • Regex
  • From:
    (?:\n*?)(?=(\{\{(?:A|a)uthority control|\{\{DEFAULTSORT|\[\[Category))
  • To:
    \n\n{{subst:#if:{{subst:#invoke:wd|label|raw}}|{{Taxonbar|from={{subst:#invoke:wd|label|raw}}}}|{{Taxonbar}}}}\n\n

Skip:

AWB4

[edit]

Setup:

Summary:

[[User:Tol/Regex#AWB4|AWB4]]: add "from" parameter to [[Template:Taxonbar]]

Find and replace:

  • Regex
  • From:
    \{\{[Tt]axonbar(?:\|from\=\s*?)?\}\}
  • To:
    {{subst:#if:{{subst:#invoke:wd|label|raw}}|{{Taxonbar|from={{subst:#invoke:wd|label|raw}}}}|{{Taxonbar}}}}

AWB5

[edit]

Setup:

Summary:

[[User:Tol/Regex#AWB5|AWB5]]: Use [[Template:Draft categories]]

Find and replace:

  1. Regex
    From:
    \n?((?:\s*?\[\[:?[Cc]ategory:(?:.*)\]\]\s*?)+)\n?
    To:
    \n\n{{Draft categories|1=\n$1\n}}\n
    Ignore unparsed content
  2. Plain text
    From:
    [[:Category
    To:
    [[Category

Skip:

  • When page contains:
    \{\{[Dd]raft cat
    • Regex
  • Redirects
  • When no changes were made
  • When page does not exist