User talk:Dank/Regex
Appearance
Notes
[edit]- Possibly useful for creating galleries:
\|\[\[\:File\:(.+?)\]\](\n)\|(.+?)\n\|\[\[.+?\]\] (.+?)\n\|\- $1 |''[[$3]]'' |$4 |alt=""
- Don't escape ! or =. This regex doesn't seem to like " ?". ".+?" may require "(.+?)". - Dank (push to talk) 14:13, 19 December 2022 (UTC)
- If you move columns, that may need to be undone later, so be prepared to paste in the previous version of the page, and copy new column info over the old columns.
Etymology tables
[edit]Adding newlines: @(.+?)@(.+?)@(.+?)@(.+?)@(.+?)@(.+?)@(.+?)@(.+?)@(.+?)@(.+?)@ @$1@$2@$3@$4@$5@$6@$7@$8@$9@$10 @ (\n)@(.+?)@(.+?)@(.+?)@(.+?)@(.+?)@(.+?)@(.+?)@(.+?)@(.+?)@(.+?) $1*$2$1*$3$1*$4$1*$5$1*$6$1*$7$1*$8$1*$9$1*$10$1 =============================================== Coombes: (\S)(\n)\| \|\|\n\| $1$2| ||$2|C add anchors: \*(\n)(.+)(\W)(\w+)\]\]''\n {{anchor|$4}}$1$2$3$4]]''$1 images for plant lists: (\n)File\:(\w+)(.+) $1[[File:$2$3|thumb|right|upright=0.7|''$2''[[#$2|←]] |alt=]] creating new rows: \*''\[\[(.+)\]\]''(.*)(\n) !scope="row" |''[[$1]]''$3| $2$3| ||$3| ||G$3|-$3 Removing gli-links \{\{gli\|(\w+)\}\} [[#$1|$1]] Swapping 2nd and 3rd cols: \!scope([^\n]+)(\n)\|([^\n]+)\n\|''\[\[([^\]]+)\]\]'' or \!scope([^\n]+)(\n)\|([^\n]+)\n\| — !scope$1$2|''[[$4]]''$2|$3 or !scope$1$2| — $2|$3 ================================== Adding * to red links: (\w+) (\w+)(.{0,4})\]\]('?'?)(.*)(\n)\|(.{1,3})\|\| $1 $2$3]]$4*$5$6|$7|| Replacing * with link to genus: \[\[(\w+) (\w+)\]\]''\* [[$1 $2]]''[[$1|*]] Adding 3 links: " ?\| ?''(\w+) (\w+), (\w+) (\w+), (\w+) (\w+)'' ?(\n) "|''[[$1 $2]], [[$3 $4]], [[$5 $6]]''$7 Adding 2 links: " ?\| ?''(\w+) (\w+), (\w+) (\w+)'' ?(\n) "|''[[$1 $2]], [[$3 $4]]''$5 Adding 1 link: " ?\| ?''(\w+) (\w+)(\*?)'' ?(\n) "|''[[$1 $2]]''$3$4 Or: \n\| ?''(\w+) (\w+)(\*?)'' ?(\n) $4|''[[$1 $2]]''$3$4 Searching for piped species links: \[\[.+\|.+\]\].*\n\|.+\|\| ================== Creating the x2 table entries: \*\*(\w+) x2(.+)(\n)\*\*(.*)\n !scope="row" |''$1''$3|rowspan="2"| L ||rowspan="2"|$2$3|rowspan="2"|$3|H || ||$3|-$3!scope="row" |''$4''$3|H || ||$3|-$3 ... and then the x1's: \*\*(\w+)(.+)(\n) !scope="row" |''$1''$3|L ||$2$3| $3|H || ||$3|-$3 transfer Coombes: c(\d{2,3})(.*)(\n)(.*\n)?\| \|\| \|\| $2$3$4| || ||C{{sfn|Coombes|p=$1}} delete " h " L to G: L \|\|(.+) G G ||$1 Remove some H's: x (.+)(\n)(.+)\n\|H \|(.+)\n $1$2$3$2| |$4$2 ============= Changing pages numbers to Coombes citations: \|\|(\d{2,3})(\n) ||C{{sfn|Coombes|p=$1}}$2 creating the last 3 columns: \|(\{\{sfn\|Harrison\}\})?(\{\{sfn\|Coo.+)?(\n)\|\- |$1 || ||$2$3|- and then adding "C" to Coombes: \|\|(\{\{sfn\|Coo.+\}\})(\n) ||C$1$2 italicizing before *: '?'?(\w+)'?'?(\S?)'?'?\* ''$1''$2{{sfn|Lewis}} ... and before *...*: '?'?(\w+)'?'?(\S?)'?'?\*(.+)\*(.*\n) ''$1''$2$3*$4 rowspan="2": \!(.+), (\w+)''(\n)\|(.+)\|\|(.+)\n\| !$1''$3|rowspan="2"|$4||rowspan="2"|$5$3|rowspan="2"| Adding a row: * $1!scope="row" |''''$1| L || $1|$1| || ||$1|-$1 Replacing codes for references: ([ \n\|])L([ \n\|]) $1{{sfn|Lewis}}$2 Creating the main table for F–H: \*(.+?) (.+?) (.+?)(\n) |-$5!scope="row" |''$1''$5| L || $2$5|''$3''$5|$4$5 Filling in page numbers: (\d{2,3})(.*\n)\*(\w+)([^\d]+?\n) $1$2*$3 $1$4 (h c\d{2,3})(\n) $2|- $1 ([^-])(\n) $1||$2 Combining Coombes and Harrison lines: (\w+)\n\*\1 (\d{2,3}) $1 h c$2 \|\s?(\w+)\s?(\n) !scope="row" |''$1''$2| || $2|''[[$1]]'' $2|{{sfn|Stearn}}{{sfn|Gledhill}}$2 ''''(\s*\n.+\n.{1,2}''\[\[)(\w+)\]\]'' ''$2''$1$2]]'' \s(p\d{2,3})\sh\sg -> h g $1 \|- \n\| (\w+) -> }}\n|-\n!scope="row" |''$1''\n| ||\n|''[[$1]]''\n|{{ ceae (\n)\*(\w+)\n ceae$1*$2 ^$1 remove a duplicate line: (\n[^\n]+)\1 $1 remove an initial-duplicate line: (\n[^\n]+)\1(.*)(\n) $1$2$3 red links: \*\[\[(\w+)\]\] (\w+ceae)\$(\n) OR \*\[\[(\w+) \(plant\)\]\] (\w+ceae)(\n) *[[$2|$1]] $2$3 add (plant): \*\[\[(\w+)\]\] (\w+ceae)`(\n) *[[$1 (plant)|$1]] $2$3 test for (plant): \*\[\[(\w+)\]\] (\w+ceae)\&(\n) *[[$1 (plant)]] $2$3 ... and fix that: \*\[\[(\w+) \(plant\)\]\] (\w+)\& *[[$1 (plant)|$1]] $2 ... and lose the remaining (plant)'s \*\[\[(\w+) \(plant\)\]\] (\w+)\\ *[[$1]] $2\ listify: \|\-.*(\n)\!.+\|(?:''\[\[)?(\w+)\]\]''\n[^\n]+\n\| {0,2}\[\[(\w+ceae).+\n.*\n *$2 $3$1 same genus, different family: (\n\*\w+ )\w+ceae\1 moving not-dones to the end: \*(\[\[.+\]\] \w+ceae)(\n) *z$1$2 moving Stearn to the end: \*([^\n]+)\/(\n) *z$1/$2 PDFs (\n)(.*?)(\d)B $1$2$3$1*B (\n)(.*?)\)B $1$2)$1*B \n([^\*])B $1B (\n) B([^\n]+)\n\n $1B$2 (\n)\*[^z][^\n]+\n $1 (\*zB[^\n]{1,350})[^\n]{0,7000}(\n) $1$2 \*B(.*?)\\.*?(\n) *B$1$2 \*B(.*?) und (.*?),.*?(\n) *B$1 und $2$3 (\n)\*B(\w+) .*?\(.*?\)\_? $1*B$2 Delete everything after the last ): (\*\[\[.*\))[^\n\)]+?(\n) $1$2 list to table \*\[\[(.+?)\]\] (\w+) (.*?)(\n) |-$4!scope="row" |''[[$1]]''$4|$3$4|[[$2]]$4| Bu$4 search for \!scope(.+?)(\n)\|[^\(\[]+\([^bdc\[\d\?](.+?)\n data-sort-value \!scope(.*?)(\n)\|\[\[(.*?)(\S+)\]\](.*?)\n !scope$1$2|data-sort-value="$4"|[[$3$4]]$5$2 \!scope(.*?)(\n)\|([^d].+?)(\S+) \((.+?)\n !scope$1$2|data-sort-value="$4"|$3$4 ($5$2 \!scope(.*?)(\n)\|([^d]) !scope$1$2|data-sort-value=""|$3 remove text after 2nd link \*\[\[(.+?)\]\] ?(\w+ceae) ?\[\[(.+?)\]\] ?\((.+?)\).+?(\n) *[[$1]] $2 [[$3]] ($4)$5 Add ill (\w+) (\w+)\\(\w\w)2 {{ill|$1 $2|$3}} (\w+) (\w+) (\w+)\\(\w\w)3 {{ill|$1 $2 $3|$4}} Convert Q codes: \] (\w+ceae) ([^(\n]+?\w)(Q\d+) ] $1 [[$2]] <small>[<nowiki/>[[d:$3#sitelinks-wikipedia|site links]]]</small> \| ?([^\|]+?\w)(Q\d+) |[[$1]] <small>[<nowiki/>[[d:$2#sitelinks-wikipedia|site links]]]</small> (\w)(Q\d+) $1@]] <small>[<nowiki/>[[d:$2#sitelinks-wikipedia|site links]]]</small> '(\w+)'_, _BG, -), _-_, _–_, x), fl., \.\w \!scope\=(.+?)(\n)\|(.+?)\n(.+?)\n(.+?)\n\|\-\n\!scope(.+?)\n\|ditto\n !scope=$1$2|rowspan="2" $3$2$4$2$5$2|-$2!scope$6$2 adding comma after first closed paren (note end spaces): (\n)(.+?)\) $1$2), removing "z" rows \!scope\="row" ? ?\|z(\n).+?\n.+?\n.+?\n(\|\-)? (\n)\{\{anchor {{anchor (\n)\n\!scope $1!scope table to list \|\-(\n).+?\|''\[\[(.+?)\]\]''\n\|(.+?)\n\|\[\[(\w+)\]\]\n\| (..) *[[$2]] $4 $3 $5 moving families to the end: \*(.+?)@(.+?)(\n) *zz$1@$2$3 delete rows: \|\-.*?(\n)\!scope.+?\n\|.+?\n\| \[.+?\n\|.{1,5}\|\| ?G\n \|\-.*?(\n)\!scope.+?\n\|.+?\n\| ?\[\[\w+?\]\] \|\| \n\|.{1,5}\n \|\-.*?(\n)\!scope.+?\n\| ?\[\[\w+?\]\] \|\| \n\|.{1,5}\n rowspan\="\d" ceae\]\](\n)\| ?(\w) ceae]] || $1| $2 adding page numbers: \]\](\d{2,3})(\n)\|(.+?)\n\|(.+?)\n\| (\w\w)\n\|\- ]]$2|$3$2|$4$2| $5{{sfn|Christenhusz|p=$1}}$2|- expanding 1-page cite to 2 pages \]\<nowiki\/\>z(\n)\|(.+?)\n\|(.+?)\n\|(.{1,3})\{\{sfn\|Christenhusz\|p\=(\d\d)0\}\} ]$1|$2$1|$3$1|$4{{sfn|Christenhusz|pp=$50–$51}} last 3 columns defective in species lists: search for (\n)\|[^\|]*\|\|[^\|]*\n\|\- and (\n)\|[^\|]*\n\|\-