How to search all the taged line within a note?

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 get a list of all the content with any tag within the a note (e.g. [[note_name]]), the expected lines look like:
abc efg, #tag1
kkkmmmnnn #tag1 #tag2

Things I have tried

currently, I uses:

file:(note_name) /#.*/

This will provide all the content with any tag within the the [[note_name]] note. However, it will also returns/matches header link like:

I also tried

file:(note_name) tag:*


file:(note_name) tag:/.*/

but they don’t match any tag.

How can I improve the search term?

1 Like

As a rough start which I haven’t tested, try adding a space and/or start of line:

/(^| )#[^# ]+/

I also changed the dot to a “not # or space” (there are other characters that should be excluded too for strict correctness).

The tag: operator unfortunately doesn’t accept regular expressions (there should have been a little message about this in the interface when you tried it).

You could try using something like: file: "note name" line: /(^| )#[^#]\S+/

This will return results from the named file, on a given line which is either at the start of the line or having a space before, and doesn’t consist of more than one hash sign with at least one non space character as part of the tag.