typora-issues icon indicating copy to clipboard operation
typora-issues copied to clipboard

Help with regex - find all content of a heading

Open loopernow opened this issue 1 year ago • 0 comments

I am wondering, let's say I have a document like:

# header 1
some text. and more text.
- item
- item
And more text. Again.

# header 2
this and that. some stuff.
stuff and stuff.
## subheader 1
subheader content.
- stuff
- stuff

What regex would find the first occurrence of a header, everything beneath it, and then stop at the next header?

Further, what regex would find the first occurrence of a header, everything beneath it, and then stop at the next _sub_header?

Practical application: As a writer, perhaps I want to reorganize my document by moving a heading and all the content related to it to another part of the document. Finding a heading and all of the content in it would allow me to easily select that section for cutting and pasting.

loopernow avatar Feb 14 '24 02:02 loopernow