[HELP] Regex that filters drafts with open taskpaper tasks

Hello community. I’m seeking assistance with a regular expression I tried to build and would eventually like to use to define a workspace.

The intended behavior I’m seeking is, using the taskpaper syntax, filter all drafts that have open tasks. I use a daily draft to add and complete tasks. Sometimes tasks aren’t finished, and in these instances, I thought defining a workspace would be an ideal solution to show all drafts with open tasks. To achieve this, I figured a regex could easily match lines that contain a dash but do not have an @done or @things tag.

I seemingly built a working expression on Regex101. Here is an example. And, the regex (- ?)(?!.*@(?:done|things)).*$.

But, in Drafts, the regex returns no results when used in the search. I’m afraid I’ve reached the limit of my regex knowledge. I’m open to feedback about what I did wrong or could have done better. I’d greatly appreciate anyone who can offer their advice. Thanks so much!

1 Like

Using regular expressions in a query for drafts is different than using it within the contents of an individual string.

You wrote a regular expression that would return matches in the contents of a draft. When you are querying for drafts using regular expression, you need to write expressions that would match the entire content of a draft. There’s no line matching, no multiple results/matches.

So if you need your expression to say “find this with anything before or after it”. Not tested, but likely the below would work:

.*(- ?)(?!.*@(?:done|things)).*