Issue Searching for Markdown Headers

I’m trying to find all of my drafts that have the # character in the top line, but not drafts that start with ## or ###, etc. When I use the search query title:# -##, I get drafts that start with a first-level markdown header (#), but have no second-level headers (##) in the draft.

My goal is to find ideas I have saved worth developing, which always have a first-level header but also sometimes have other headers within the draft. Other drafts, unfortunately, have the second-level header as the top line, and I’d like to omit those from the search results.

Attempting another search with title:# title:-## doesn’t seem to work, neither does title:# -title:##. What am I doing wrong, how am I misunderstanding the title search feature? I’m basically just trying to do a Boolean search within the “title” field, and I just can’t figure it out.

Try this:

/^# .*/

If I’m right, it should match any draft that starts with a single octothorpe followed by a space.

1 Like

Marvelous! That does the trick. I also aim to omit certain terms from the title line (I have a lot of # Journal for YYYY-MM-DD lying around,) but if what you’re telling me is that RegEx holds the key, then I suppose I can do some homework to learn a little more about how to use it.

Thanks so much!

Actually, it turns out title: -"journal" /^# .*/ did the trick. I guess I just needed to put the “Title” modifier first.

1 Like