User:Xenwolf/Regex snippets: Difference between revisions

From Xenharmonic Wiki
Jump to navigation Jump to search
Xenwolf (talk | contribs)
removed one rule (already included in another rule)
Xenwolf (talk | contribs)
links to internal pages include links to intervals
Line 21: Line 21:
| <code><nowiki>[[\1]]</nowiki></code>
| <code><nowiki>[[\1]]</nowiki></code>
| simplify links to interval pages
| simplify links to interval pages
|-
| <code><nowiki>\[\[(\w[^|]+?)\|\1\]\]</nowiki></code>
| <code><nowiki>[[\1]]</nowiki></code>
| simplify internal links
|-
|-
| <code><nowiki><span style="font-size: 70%; vertical-align: super;">(\d+)</span></nowiki></code>
| <code><nowiki><span style="font-size: 70%; vertical-align: super;">(\d+)</span></nowiki></code>

Revision as of 16:49, 27 September 2020

These are regular expressions I use in Notepad++, they are also usable in Perl.

Pattern to Find Replace by Purpose
\|\s*([^|]+?)\s*&gt; {{Monzo| \1 }} replace inline-monzos in tables #1 (cell definitions in same lines)
<nowiki>\s*\|\s*([^<]+?)\s*</nowiki>&gt; {{Monzo| \1 }} replace inline-monzos in tables #2 (cell definitions on separate lines)
^([!|]) \| \1 remove empty style definitions for table cells
\[\[([\d/]+)\|\1\]\] [[\1]] simplify links to interval pages
<span style="font-size: 70%; vertical-align: super;">(\d+)</span> <sup>\1</sup> simplify superscript for exponents
^(=+)\s*(.+)\s*(\1) *$ \1= \2 \1= downgrade heading structure from (h1, h2, h3, ...) to (h2, h3, h4, ...)
^\|([^\s{}-]) | \1 consistent spacing for table cells (when rows are aligned vertically)
\[\[([- \w]+)_ [[\1  iterative removal of redundant underscores
style="text-align:\w+;" \| ? remove inline CSS style of text alignment in table cells
^([!|])([^-+} ]+) \1 \2 add one space after cell metachar
(<span style="">)+(.+?)(</span>)+ \2 remove nonsense spans Use with caution!
description