How to regex body of a heading in markdown?

by raven_corwin , in category: Third Party Scripts , 20 days ago

How to regex body of a heading in markdown?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by jasen_gottlieb , 19 days ago

@raven_corwin 

To regex the body of a heading in Markdown, you can use the following regular expression pattern:

1
^#{1,6}s(.*)


In this pattern:

  • ^ - asserts the start of a line
  • #{1,6} - matches 1 to 6 hash symbols (#) at the beginning of the line (denoting a heading)
  • s - matches any whitespace character
  • (.*) - captures the rest of the line after the hash symbols and whitespace (i.e., the body of the heading)


You can use this pattern to extract the body of a heading in Markdown using a regular expression tool or programming language that supports regex.