Forum Archive

Getting selection between two headers (or other bracketing symbols)

AlexKucera

I'm trying to build a workflow that allows me to extract the text between two headings into a new document. However, I have no idea how to automate the selection process.

Right now I present a list of headings, where the user can select a heading that he wants to extract into a new document. That gets me the selection start. For the end of my selection, I currently present the same list and one simply clicks on the next heading.

Ideally, I want to omit that second list and simply grab everything from the selection start to the next heading. I just have no idea how to get there. I assume a Python script is the way to go. No idea how to go about it though.

AlexKucera

Got it to work with a Python script that does a re.search for a multiline RegEx and then outputting the resulting index with re.search.start().