Remove automatically the content under a specific header

First, search the help docs and this forum. Maybe your question has been answered! The debugging steps can help, too. Still stuck? Delete this line and proceed.

What I’m trying to do

I try to create a template to remove the content under a specific header in Daily Notes.

Things I have tried

<%*
const view = app.workspace.activeLeaf.view;
const editor = view.editor;
const header = “### New Heading”;
const headerRegex = new RegExp((${header}\\n)([\\s\\S]*?)(?=\\n## |$), “g”);
const newContent = tp.file.content.replace(headerRegex, “$1”);
tR = newContent;
%>
what this code does, is creating a new file with the const header empty and append it to the original one.
I can’t figure out how to deal only with the content under the heading.

Why do you do this? Why do you add the header/content if you don’t want it? Why is there references to the editor when you don’t use it?

If you want to create another file, why don’t you use 'tp.file.create_new()`?

Please try to explain your use case a little more, as we then might be able to help you and not just ask questions… :smiley:

I have a section with the task overdue (dataview) and 3 random notes to remind myself about that. This section is relevant only for the current day, so at the end of the day I want to remove those queries.

You can actually make a dataview query that would show different results depending on the current date, so you don’t have to edit the file itself.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.