User:Xenwolf/Regex snippets: Difference between revisions

From Xenharmonic Wiki
Jump to navigation Jump to search
Xenwolf (talk | contribs)
m fix my wiki markup
ArrowHead294 (talk | contribs)
mNo edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
These are regular expressions I use in Notepad++, they are also usable in [[Perl]].
These are regular expressions I use in Notepad++, they are also usable in {{w|Perl}}.


{| class="wikitable"
{| class="wikitable"
! width="56%" | Pattern to Find
|-
! width="14%" | Replace by
! style="width: 50%;" | Pattern to Find
! style="width: 14%;" | Replace by
! Purpose
! Purpose
|-
|-
Line 53: Line 54:
| <code><nowiki><\1>\2</\1></nowiki></code>
| <code><nowiki><\1>\2</\1></nowiki></code>
| simplify super- and subscript
| simplify super- and subscript
|-
| <code><nowiki>(\d+),(\d+)</nowiki></code>
| <code><nowiki>\1.\2</nowiki></code>
| replace decimal comma by decimal point
|-
|-
| <code><nowiki></nowiki></code>
| <code><nowiki></nowiki></code>
Line 58: Line 63:
| description
| description
|}
|}
[[Category:Regular expressions]]

Latest revision as of 15:44, 4 December 2024

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: ?\d\d%; vertical-align: super;">(.+)</span> <sup>\1</sup> proper superscript
<font style="vertical-align:super;font-size:0.\dem;">(.+)</font> <sup>\1</sup> proper superscript
^(=+)\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!
<span style="vertical-align: (\w+);">([^<]+)</span> <\1>\2</\1> simplify super- and subscript
(\d+),(\d+) \1.\2 replace decimal comma by decimal point
description