Regular Expressions 101

Community Patterns

MD h1 change to block with anchor

0

Regular Expression
PCRE2 (PHP >=7.3)

/
(#.*) &(.*)
/
gm

Description

Find any lines starting with # and followed by anchor name with & and wrap it into html so that we start with this:

Title &anchor

and finish with something like this:

<a name = "anchor"> # Title <a href = "link/#anchor">→</a>
Submitted by anonymous - 2 years ago (Last modified 2 years ago)