User:SOTO/bot tricks

= Categories =

Step 1
 python pwb.py add_text -cat:"category" -text:"" -pt:2 -except:"New category"

Step 2
 python pwb.py replace -cat:"New category" -regex "\[\[Category:(New category)\]\]\n([\s\S]*)\n\[\[Category:(.*?)\]\]" "\2\n\n" -pt:2 Absolute bottom  python pwb.py replace -cat:"New category" -regex "\[\[Category:(New category)\]\]\n([\s\S]*)\n\[\[Category:(.*?)\]\]" "\2\n\n" "\[\[Category:(New category)\]\]\n\[\[Category:(.*?)\]\]" "\n" -pt:2

Adding FTRW category only if contains
 python pwb.py replace -catr:"Example" -regex "\{\{[Ww]ikipediainfo([\s\S]*)\[\[Category:(.*?)\]\]" "{{wikipediainfo\1\n" -excepttext:"Example from the real world" -pt:2

Locations visited by the good Doc
 pwb.py replace "-cat:Example" "-regex" "\[\[Category:Locations visited by the(.*?)Doctor\]\]" "" "-pt:2"

= Templates =

Implementing
 python pwb.py replace -regex "\[\[(:wikipedia|wikipedia):(.*?)\|(.*?)\]\]" "" "\[\[(:wikipedia|wikipedia):(.*?)\|(.*?)\]\]" "" "\{\{(w|wi)\|(.*?)\|\2\}\}" "" "\{\{(w|wi)\|(\w)(.*?)\|(\w)\3\}\}" "" "\{\{(w|wi)\|(\w)(.*?)\|(\w)\3(s)\}\}" "" -summary:"Converting to and " -start:! -pt:2

Catch-all template order/spacing standardisation
 python pwb.py replace -regex "\{\{([Tt]itle dab away|[Rr]eal world)\}\}\{\{([Rr]eal world|[Tt]itle dab away)\}\}" "\n" "}}\n{{Infobox" "\{\{(.*?)stub\}\}\n\{\{[Tt]itle dab away\}\}\n\{\{[Rr]eal world\}\}" "\n\n" "\{\{(.*?)stub\}\}\{\{[Tt]itle dab away\}\}" "\n" "\{\{[Rr]eal world\}\}\n\{\{[Tt]itle dab away\}\}\n{\{(.*?)stub\}\}" "\n\n" "\{\{[Tt]itle dab away\}\}\n\{\{(.*?)stub\}\}\n{\{[Rr]eal world\}\}" "\n\n" "\{\{real world\}\}\{\{(.*?)stub\}\}\n\{\{title dab away\}\}\n([\s\S]*?)\}\}" "\n\n\2}}" "\{\{ImageLink(.*?)\}\}\{\{real world\}\}\{\{title dab away\}\}\{\{Infobox" "\n\n\n{{Infobox" "\{\{ImageLink(.*?)\}\}( *)\n\{\{[Rr]eal world\}\}( *)\n\{\{[Tt]itle dab away\}\}" "\n\n" "\{\{ImageLink(.*?)\}\}\{\{[Rr]eal world\}\}\{\{[Tt]itle dab away\}\}" "\n\n{{ImageLink\1}}" "\{\{[Rr]eal world\}\}\{\{[Tt]itle dab away\}\}" "\n" "\{\{real world\}\}\{\{[Rr]etitle\|(\'\'|.)(\{\{PAGENAME\}\})(\'\'|.)\}\}" "{{retitle|\1\2\3}}\n" "\{\{real world\}\}\{\{[Rr]etitle\|(.*?)\}\}" "{{retitle|\1}}\n" "\{\{real world\}\}\{\{ImageLink(.*?)\}\}\{\{[Tt]itle dab away\}\}" "\n\n{{ImageLink\1}}" "\{\{real world\}\}\{\{ImageLink(.*?)\}\}" "\n{{ImageLink\1}}" "\{\{real world\}\}\n\{\{ImageLink(.*?)\}\}\n\{\{title dab away\}\}" "\n\n{{ImageLink\1}}" "\{\{real world\}\}\{\{target years\}\}" "\n{{target years}}" "\{\{[rR]eal world\}\}" "\n" "\{\{[rR]eal world\}\} \n" "\n" "\{\{[rR]eal world\}\}(.+)\n" "\n\1\n" "\{\{[rR]eal world\}\}\n\n" "{{real world}}\n" "\{\{title dab away\}\}\n\{\{real world\}\}\n\{\{(.*?)stub\}\}\n([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\}\}" "\n{{real world}}\n\2\4\6\8\10}}" "\{\{title dab away\}\}\n\{\{real world\}\}\n\{\{(.*?)stub\}\}\n([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\}\}" "\n{{real world}}\n\2\4\6\8}}" "\{\{title dab away\}\}\n\{\{real world\}\}\n\{\{(.*?)stub\}\}\n([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\}\}" "\n{{real world}}\n\2\4\6}}" "\{\{title dab away\}\}\n\{\{real world\}\}\n\{\{(.*?)stub\}\}\n([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\}\}" "\n{{real world}}\n\2\4}}" "\{\{title dab away\}\}\n\{\{real world\}\}\n\{\{(.*?)stub\}\}\n([\s\S]*?)\}\}" "\n{{real world}}\n\2}}" "\{\{real world\}\}\n\{\{(.*?)stub\}\}\n\{\{title dab away\}\}\n([\s\S]*?)\}\}" "\n{{real world}}\n\2}}" "\n\|(.*?)\}\}\{\{" "\n|\1\n}}{{" "\}\}\{\{(.*?) stub\}\}\'\'\'" "}}\n" "\}\}\{\{(.*?) stub\}\}\{\{[yY]ou may(.*?)\}\}" "}}\n" "\}\}\{\{(.*?) stub\}\}\n\{\{(.*?)\}\}\'\'\'" "}}\n\n" -pt:2 -summary:"Standardising template spacing and order" -transcludes:"real world"

Autolinking infobox variables
 python pwb.py replace -regex "\n\|( *)featuring( *)=( *)\[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\]" "\n|\1featuring\2=\3\4\n|\1featuring2\2=\3\5\n|\1featuring3\2=\3\6\n|\1featuring4\2=\3\7\n|\1featuring5\2=\3\8\n|\1featuring6\2=\3\9\n|\1featuring7\2=\3\10\n|\1featuring8\2=\3\11\n|\1featuring9\2=\3\12\n|\1featuring10\2=\3\13" "\n\|( *)featuring( *)=( *)\[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\]" "\n|\1featuring\2=\3\4\n|\1featuring2\2=\3\5\n|\1featuring3\2=\3\6\n|\1featuring4\2=\3\7\n|\1featuring5\2=\3\8\n|\1featuring6\2=\3\9\n|\1featuring7\2=\3\10\n|\1featuring8\2=\3\11\n|\1featuring9\2=\3\12" "\n\|( *)featuring( *)=( *)\[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\]" "\n|\1featuring\2=\3\4\n|\1featuring2\2=\3\5\n|\1featuring3\2=\3\6\n|\1featuring4\2=\3\7\n|\1featuring5\2=\3\8\n|\1featuring6\2=\3\9\n|\1featuring7\2=\3\10\n|\1featuring8\2=\3\11" "\n\|( *)featuring( *)=( *)\[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\]" "\n|\1featuring\2=\3\4\n|\1featuring2\2=\3\5\n|\1featuring3\2=\3\6\n|\1featuring4\2=\3\7\n|\1featuring5\2=\3\8\n|\1featuring6\2=\3\9\n|\1featuring7\2=\3\10" "\n\|( *)featuring( *)=( *)\[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\]" "\n|\1featuring\2=\3\4\n|\1featuring2\2=\3\5\n|\1featuring3\2=\3\6\n|\1featuring4\2=\3\7\n|\1featuring5\2=\3\8\n|\1featuring6\2=\3\9" "\n\|( *)featuring( *)=( *)\[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\]" "\n|\1featuring\2=\3\4\n|\1featuring2\2=\3\5\n|\1featuring3\2=\3\6\n|\1featuring4\2=\3\7\n|\1featuring5\2=\3\8" "\n\|( *)featuring( *)=( *)\[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\]" "\n|\1featuring\2=\3\4\n|\1featuring2\2=\3\5\n|\1featuring3\2=\3\6\n|\1featuring4\2=\3\7" "\n\|( *)featuring( *)=( *)\[\[(.*?)\]\], \[\[(.*?)\]\], \[\[(.*?)\]\]" "\n|\1featuring\2=\3\4\n|\1featuring2\2=\3\5\n|\1featuring3\2=\3\6" "\n\|( *)featuring( *)=( *)\[\[(.*?)\]\], \[\[(.*?)\]\]" "\n|\1featuring\2=\3\4\n|\1featuring2\2=\3\5" "\n\|( *)featuring( *)=( *)\[\[(.*?)\]\]\n" "\n|\1featuring\2=\3\4\n" "\n\|( *)featuring( *)=( *)\{\{il\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\}\}" "\n|\1featuring\2=\3\4\n|\1featuring2\2=\3\5\n|\1featuring3\2=\3\6\n|\1featuring4\2=\3\7\n|\1featuring5\2=\3\8\n|\1featuring6\2=\3\9\n|\1featuring7\2=\3\10\n|\1featuring8\2=\3\11\n|\1featuring9\2=\3\12\n|\1featuring10\2=\3\13" "\n\|( *)featuring( *)=( *)\{\{il\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\}\}" "\n|\1featuring\2=\3\4\n|\1featuring2\2=\3\5\n|\1featuring3\2=\3\6\n|\1featuring4\2=\3\7\n|\1featuring5\2=\3\8\n|\1featuring6\2=\3\9\n|\1featuring7\2=\3\10\n|\1featuring8\2=\3\11\n|\1featuring9\2=\3\12" "\n\|( *)featuring( *)=( *)\{\{il\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\}\}" "\n|\1featuring\2=\3\4\n|\1featuring2\2=\3\5\n|\1featuring3\2=\3\6\n|\1featuring4\2=\3\7\n|\1featuring5\2=\3\8\n|\1featuring6\2=\3\9\n|\1featuring7\2=\3\10\n|\1featuring8\2=\3\11" "\n\|( *)featuring( *)=( *)\{\{il\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\}\}" "\n|\1featuring\2=\3\4\n|\1featuring2\2=\3\5\n|\1featuring3\2=\3\6\n|\1featuring4\2=\3\7\n|\1featuring5\2=\3\8\n|\1featuring6\2=\3\9\n|\1featuring7\2=\3\10" "\n\|( *)featuring( *)=( *)\{\{il\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\}\}" "\n|\1featuring\2=\3\4\n|\1featuring2\2=\3\5\n|\1featuring3\2=\3\6\n|\1featuring4\2=\3\7\n|\1featuring5\2=\3\8\n|\1featuring6\2=\3\9" "\n\|( *)featuring( *)=( *)\{\{il\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\}\}" "\n|\1featuring\2=\3\4\n|\1featuring2\2=\3\5\n|\1featuring3\2=\3\6\n|\1featuring4\2=\3\7\n|\1featuring5\2=\3\8" "\n\|( *)featuring( *)=( *)\{\{il\|(.*?)\|(.*?)\|(.*?)\|(.*?)\}\}" "\n|\1featuring\2=\3\4\n|\1featuring2\2=\3\5\n|\1featuring3\2=\3\6\n|\1featuring4\2=\3\7" "\n\|( *)featuring( *)=( *)\{\{il\|(.*?)\|(.*?)\|(.*?)\}\}" "\n|\1featuring\2=\3\4\n|\1featuring2\2=\3\5\n|\1featuring3\2=\3\6" "\n\|( *)featuring( *)=( *)\{\{il\|(.*?)\|(.*?)\}\}" "\n|\1featuring\2=\3\4\n|\1featuring2\2=\3\5" "\n\|( *)featuring( *)=( *)\{\{il\|(.*?)\}\}\n" "\n|\1featuring\2=\3\4\n" "\n\|( *)featuring( *)=( *)\[\[(.*?)\]\]\\[\[(.*?)\]\]\\[\[(.*?)\]\]\\[\[(.*?)\]\]\\[\[(.*?)\]\]\\[\[(.*?)\]\]\\[\[(.*?)\]\]\\[\[(.*?)\]\]\\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]" "\n|\1featuring\2=\3\4\n|featuring2\2=\3\5\n|featuring3\2=\3\6\n|featuring4\2=\3\7\n|featuring5\2=\3\8\n|featuring6\2=\3\9\n|featuring7\2=\3\10\n|featuring8\2=\3\11\n|featuring9\2=\3\12\n|featuring10\2=\3\13" "\n\|( *)featuring( *)=( *)\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]" "\n|\1featuring\2=\3\4\n|featuring2\2=\3\5\n|featuring3\2=\3\6\n|featuring4\2=\3\7\n|featuring5\2=\3\8\n|featuring6\2=\3\9\n|featuring7\2=\3\10\n|featuring8\2=\3\11\n|featuring9\2=\3\12" "\n\|( *)featuring( *)=( *)\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]" "\n|\1featuring\2=\3\4\n|featuring2\2=\3\5\n|featuring3\2=\3\6\n|featuring4\2=\3\7\n|featuring5\2=\3\8\n|featuring6\2=\3\9\n|featuring7\2=\3\10\n|featuring8\2=\3\11" "\n\|( *)featuring( *)=( *)\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]" "\n|\1featuring\2=\3\4\n|featuring2\2=\3\5\n|featuring3\2=\3\6\n|featuring4\2=\3\7\n|featuring5\2=\3\8\n|featuring6\2=\3\9\n|featuring7\2=\3\10" "\n\|( *)featuring( *)=( *)\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]" "\n|\1featuring\2=\3\4\n|featuring2\2=\3\5\n|featuring3\2=\3\6\n|featuring4\2=\3\7\n|featuring5\2=\3\8\n|featuring6\2=\3\9" "\n\|( *)featuring( *)=( *)\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]" "\n|\1featuring\2=\3\4\n|featuring2\2=\3\5\n|featuring3\2=\3\6\n|featuring4\2=\3\7\n|featuring5\2=\3\8" "\n\|( *)featuring( *)=( *)\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]" "\n|\1featuring\2=\3\4\n|featuring2\2=\3\5\n|featuring3\2=\3\6\n|featuring4\2=\3\7" "\n\|( *)featuring( *)=( *)\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]" "\n|\1featuring\2=\3\4\n|featuring2\2=\3\5\n|featuring3\2=\3\6" "\n\|( *)featuring( *)=( *)\[\[(.*?)\]\]\<br */*\>\[\[(.*?)\]\]" "\n|\1featuring\2=\3\4\n|featuring2\2=\3\5" "\|( *)(featuring|\1featuring.*)( *)=( *)(.*?)\|(.*?)\n" "|\1\2\3=\4\5\n" "\|( *)(featuring|\1featuring.*)( *)=( *)(.*?)\|(.*?)\n" "|\1\2\3=\4\5\n" "\|( *)(featuring|\1featuring.*)( *)=( *)(.*?)\|(.*?)\n" "|\1\2\3=\4\5\n" "\|( *)(featuring\d)  " "|\1\2  " "\|( *)(featuring\d\d)    " "|\1\2  " -transcludes:"Infobox Story" -summary:"Autolinking featuring variable" -pt:2

Checking for double NameSorts
<pre style="background:black!important;color:white"> python pwb.py replace -regex "\{\{NameSort\}\}\n([\s\S]+)\{\{NameSort\}\}" "\1" -pt:2 -transcludes:"NameSort"

= General =

Piped italics
<pre style="background:black!important;color:white"> python pwb.py replace -regex "\[\[(TV|AUDIO|COMIC|PROSE|GAME|REF|DOC|WC|NOTVALID)\]\]: \[\[(.*?) \((.*?)\)\|(.*?)\]\]" "\1: \4" "\[\[(TV|AUDIO|COMIC|PROSE|GAME|REF|DOC|WC|NOTVALID)\]\]: \[\[(.*?)\|\2\]\]" "\1: \2" -summary:"Piped italics fix: P1" -start:! -pt:2 <pre style="background:black!important;color:white"> python pwb.py replace -regex "\[\[(.*?)\|\1\]\]" "\1" "\[\[(.*?) \((.*?)\)\|\1\]\]" "\1" -summary:"Piped italics fix: P2" -start:! -pt:2 <pre style="background:black!important;color:white"> python pwb.py replace -regex "\[\[(.*?)\|(.*?)\]\]" "\2" -summary:"Piped italics fix: P3" -start:! -pt:2

Empty span tags
<pre style="background:black!important;color:white"> python pwb.py replace -regex "(\<span\>|\</span\>|\<span class=..\>)" "" -summary:"Removing empty tags" -pt:2 -start:!

Disambig full titles
<pre style="background:black!important;color:white"> python pwb.py replace -cat:"Disambiguation pages" -regex "\*( *)\[\[(.*?) \((.*?)\)\|\2\]\]" "*\1\2 (\3)" -pt:2

Overly complicated spacing fix
<pre style="background:black!important;color:white"> python pwb.py replace -regex "\{\{Infobox([\s\S]*?)\}\}\n\{\{([Yy]ou may)" "{{you may" "\{\{Infobox([\s\S]*?)\}\}\n\{\{([Dd]ab page)" "{{dab page" "\{\{Infobox([\s\S]*?)\}\}\n\{\{([Ww]ikipediainfo)" "{{Infobox\1}}{{wikipediainfo" "(\}\}\{\{|\{\{)([sS]tub|.*? stub|wikipediainfo)\}\}\{\{(you may|dab page)" "\1\2}}\n{{\3" "\n\}\}\{\{(.*?)\}\}\{\{(you may|dab page|wikipediainfo)" "\n}}{{\1}///}{{\2" "\{\{Infobox([\s\S]*?)(\]\]|\)|\w)\}\}\{\{(you may|dab page|wikipediainfo)" "{{Infobox\1\2\n}}{{\3" "\}\/\/\/\}" "}}" "\{\{Infobox([\s\S]*?)\}\}\n\n" "{{Infobox\1}}\n" -summary:"Template spacing" -start:! -pt:2

Before headings
<pre style="background:black!important;color:white"> python pwb.py replace -regex "(\w|\)|\.|\')\n==" "\1\n\n==" "(\w|\)|\.|\')( *)\n==" "\1\n\n==" "\n\n\n==" "\n\n==" -excepttext:"PLEASE do not alter" -summary:"Vertical spacing" -start:! -pt:2

Horizontal spacing (=/*)
This baasically does the job, though it's messy and inefficient: <pre style="background:black!important;color:white"> python pwb.py replace -regex "\n(\*+)(\S)" "\n\1 \2" "(==+)(\S.*?\S)(==+)" "\1 \2 \3" "(=+|==|===|====) = (.*?) = (=+|==|===|====)" "\1= \2 =\3" "=== =" "====" "(\*+|\*\*|\*\*\*) \* (.*?)" "\1* \2" -start:! -pt:2

= Videos =

Step 2
Find-and-replace list into a usable format. <pre style="background:black!important;color:white">python pwb.py replace "" "" -pt:2 -page:"File:Video name 1" -page:"File:Video name 2" You may have to handle videos with double quotation marks in their titles, manually.