User:Xenwolf/Regex snippets: Difference between revisions

From Xenharmonic Wiki
Jump to navigation Jump to search
Xenwolf (talk | contribs)
more specific inline monzo matching
Xenwolf (talk | contribs)
Line 28: Line 28:
| <code><nowiki>^(=+)\s*(.+)\s*(\1) *$</nowiki></code>
| <code><nowiki>^(=+)\s*(.+)\s*(\1) *$</nowiki></code>
| <code><nowiki>\1= \2 \1=</nowiki></code>
| <code><nowiki>\1= \2 \1=</nowiki></code>
| downgrade heading structure from (h1, h2, h3, ...) to (h2, h3, h4, ...)
| fix [[heading structure]] (subheadings start at h2; h1 dedicated to lemma)
|-
|-
| <code><nowiki>\[\[([- \w]+)_</nowiki></code>
| <code><nowiki>\[\[([- \w]+)_</nowiki></code>

Revision as of 16:14, 31 May 2021

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

Pattern to Find Replace by Purpose
\|\s*(-?\d+(?:\s+-?\d+)*)\s*&gt; {{Monzo| \1 }} replace inline-monzos #1
<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
\[\[(\w[^|]+?)\|\1\]\] [[\1]] simplify internal links
<span style="font-size: 70%; vertical-align: super;">(\d+)</span> <sup>\1</sup> simplify superscript for exponents
^(=+)\s*(.+)\s*(\1) *$ \1= \2 \1= fix heading structure (subheadings start at h2; h1 dedicated to lemma)
\[\[([- \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