This regex find-and-replace rule removes bold formatting from headings. Useful when copy-and-pasting or clipping such headings from somewhere.
I set this up as a custom rule in Linter that runs automatically on file save and file change.
Rule for **
regex to find:
^(#{1,6} .*?)(?<!\\)\*\*([^\n]*?)(?<!\\)\*\*
flags:
gm
regex to replace:
$1$2
Rule for <strong> and <b>
regex to find:
^(#{1,6} .*?)(?<!\\)<(b|strong)>([^<\n]*?)(?<!\\)</\2>
flags:
gm
regex to replace:
$1$3
Before
# **Hello** \**there**
# General <b>Kenobi</b>
# You are a <strong>bold</strong> one
After
# Hello \**there**
# General Kenobi
# You are a bold one
\**there** is unchanged because the rules only match two unescaped pairs and the first ** is escaped with \ here.