Searching for Notes with Only the "X" Tag and excluding others that also have this "X" tag but have other tags besides "X"

My vault has tags in YAML frontmatter as properties

Case 1

I have some notes having only the person tag i.e.,

Note 1

tags:
  - person

Case 2

Then there are some notes, that have tags besides the person tag i.e.,
Note 2

tags:
  - atag
  - person
  - adifferenttag

or
Note 3

tags:
  - person
  - atag1

or
Note 4

tags:
  - atag2
  - person

What I’m trying to do

I want to search for notes that have only the person tag but I don’t want any notes to appear in my search results that have any other tags besides the person tag i.e., Note 1 should appear but not Note 2, Note 3 or Note 4

/tags:\n\s*-\s*person\s*\n(?!.*-\s*)/
1 Like

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