Beschreibung
^((?:#|#{3,})[^#])

Ersetzen durch:\$1
Dieser reguläre Ausdruck folgendes tun:
- Spiel ein hash
- 3 oder mehr Hash
Beispiel
Live Demo
https://regex101.com/r/kE4oK6/1
Beispieltext
#Heading
##Heading
###Heading
####Heading
#####Heading
######Heading
Probe Spiele
\#Heading
##Heading
\###Heading
\####Heading
\#####Heading
\######Heading
Erklärung
NODE EXPLANATION
----------------------------------------------------------------------
^ the beginning of a "line"
----------------------------------------------------------------------
( group and capture to \1:
----------------------------------------------------------------------
(?: group, but do not capture:
----------------------------------------------------------------------
# '#'
----------------------------------------------------------------------
| OR
----------------------------------------------------------------------
#{3,} '#' (at least 3 times (matching the
most amount possible))
----------------------------------------------------------------------
) end of grouping
----------------------------------------------------------------------
[^#] any character except: '#'
----------------------------------------------------------------------
) end of \1
----------------------------------------------------------------------
Danke, warum t war sein Votum als zu breit gewählt? – frosty
Eher https://regex101.com/r/uS6xY8/2 – myf
sollten Sie Ihren Versuch posten .. – rock321987