How to match tag exactly

I use a query like this:

(filename includes file.md) OR (tag includes #name)
(not done) OR (done before in one week)
group by due
sort by due
sort by priority

But this doesn’t match #name but also #name1 #name2 etc. How can I make sure only #name is matched?

Things I have tried

Searched on the internet but couldn’t find a solution …

TX for your help!

What I’m trying to do

It seems like includes will always as part of the string, and that there is no equals variant, that I could find after a quick glance through the documentation.

However, there exists regex matches, so using that with some anchoring can get the job done:

```tasks
(filename includes file.md) OR (tag regex matches /^#name$/)
(not done) OR (done before in one week)
group by due
sort by due
sort by priority
```

The anchor used are the ^ to lock the search for the start of the string, and $ to lock the search for the end of the string. In essence that means we need to describe the entire match within those anchors. The regex is always surrounded by / ... /.

In general you shouldn’t need to know too much about regex when using it to do exact matches, but you need to take some care if you want to search for any of the following: /.[]()\//*+?

Most of these you don’t normally want in an exact match anyways, so they shouldn’t pose a big problem. If you want to search for something like #nested/tag, then you need to do /^#nested\/tag$/.

Hope this helps!

Bonus tip: How to present code properly in a forum post

If you want to showcase either markdown, or code blocks, or dataview queries properly in a forum post, be sure to add one line before and one life after what you want to present with four backticks, ````. This will ensure that any other backticks (like for code blocks) is properly shown.

Thanks: this works! #learningallthetime

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