User:Xenwolf/Regex snippets: Difference between revisions
Jump to navigation
Jump to search
m fixed generalization: I obviously mixed up the rows in https://en.xen.wiki/index.php?title=User%3AXenwolf%2FRegex_snippets&type=revision&diff=50396&oldid=50395 |
remove redundant substitution (is included in "add one space after cell metachar") |
||
Line 2: | Line 2: | ||
{| class="wikitable" | {| class="wikitable" | ||
! Pattern to Find | ! width="56%" | Pattern to Find | ||
! Replace by | ! width="14%" | Replace by | ||
! Purpose | ! Purpose | ||
|- | |- | ||
Line 29: | Line 29: | ||
| <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, ...) | | downgrade heading structure from (h1, h2, h3, ...) to (h2, h3, h4, ...) | ||
|- | |- | ||
| <code><nowiki>\[\[([- \w]+)_</nowiki></code> | | <code><nowiki>\[\[([- \w]+)_</nowiki></code> |
Revision as of 15:46, 6 December 2020
These are regular expressions I use in Notepad++, they are also usable in Perl.
Pattern to Find | Replace by | Purpose |
---|---|---|
\|\s*([^|]+?)\s*>
|
{{Monzo| \1 }}
|
replace inline-monzos in tables #1 (cell definitions in same lines) |
<nowiki>\s*\|\s*([^<]+?)\s*</nowiki>>
|
{{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=
|
downgrade heading structure from (h1, h2, h3, ...) to (h2, h3, h4, ...) |
\[\[([- \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 |