Find multiple lines of text, cut move then append

I’m interested in an action that can find any text that starts and ends with “{>> <<}”

I’d like to cut or move this text to the bottom of the same draft.

I’ve seen similar on the community but can’t locate precisely this.

Example of original text looks like this:


# Header 

Some text

Some more text. 

{>>Some text in between.<<} 

Some text. 

{>>Some more text in between.<<}
{>>Some more text in between again that is quite long and goes on for a few lines but is all contained inside of the curly arrow braces.<<} 

Some text. 

Example of desired output:


# Header 

Some text

Some more text. 

Some text. 

Some text. 

---

{>>Some text in between.<<} 

{>>Some more text in between.<<}
{>>Some more text in between again that is quite long and goes on for a few lines but is all contained inside of the curly arrow braces.<<} 

I suspect you have seen similar in terms of moving completed tasks to the end of a draft.

You should be able to tweak the following action to search for your preferred marker pair rather than the completed task syntax.

However, there is one caveat. in your example above you have a blank line between the first match and the second and third matches. Presumably this is because the second and third matches are sequential.

As a result, to exactly match the behaviour you describe, I would recommend that when you match the current line and check it, you also check if the next line is also a match. If it is not, add an extra newline to your output. If it is a match, add nothing.

2 Likes

@sylumer Thank you for pointing me in the right direction… will circle back if I have any questions.

With appreciation!