Make a search result for files only at the beginning of a word

Use case or problem

The problem is that when there are many files in the database, keywords searches become useless. For example, I have articles about ink, and when I search, it will give me useless results as “links” or “backlinks”.

Even on this forum, I can’t find any topic by keywords in the middle. But for some reason this is built into the program. ¯_(ツ)_/¯

Everything is perfectly searched for by the keywords from the beginning of the sentence.

But it doesn’t work if the search starts from the middle of a sentence or phrase.

Proposed solution

Make a search result for files only at the beginning of a word.

take some time reading the included help vault.

tldr have you tried useing quotes "ink"

Yes, I tried, but the problem is that the quotes require full occurrence of the word, otherwise there is no result. As for me, this is very inconvenient, since usually everyone searches for the beginning of a word and does not write it completely. Perhaps this is a feature, but as I said, even on this forum in a different way. Maybe I’m just dumb and don’t understand something.


You can use regular expression to do partial word matching. Something like /\sdifferen.*?/

https://help.obsidian.md/Plugins/Search

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Cheatsheet

I know, but I think regular expressions are an overcomplicated solution. In my notes, I have very long terms that are easy to mistake. I just want a simple search search like this forum or any other site. I can write “Obsidian Relea” and get the results, but it won’t work with quotes in obsidian app.

do you mean to sort search result by relevant first?

But you already can. Don’t use quotes. The problem is that you want whole word at the beginning and fuzzy at the end.

yes, as for me this search works everywhere, at least you understand me, thanks

With the RegEx “solution”, it can be nice to use \b which just means at the beginning or end of the word.

\bred\b means that red has to be at the start and the end, i.e. the isolated word “red”
\bred means that red only has to be at the start of a word.
red\b means that red only has to be at the end of a word.

\bred\b will find “the red dog” but not the “the redwood tree” and not “covered up”
red\b will find “the red dog” and “covered up” but not “the redwood tree”
\bred will find “the red dog” and “the redwood tree” but not “covered up”

/\bred/ will find any entry with a word starting with the letters: red

This seems a little less complicated than other suggestions that have been made.

1 Like

The second option works great, thanks. It is easier to write, but still awkward for quick search. I don’t understand why this behavior is not the default. Or at least the same behavior in the with “Quoted strings”.

There is no result in the photo like a passWORD and that’s great. It is also not necessary that the word exactly matches like in “Quoted strings”.

Unfortunately for the russian language this dosen’t work

RegEx frequently has problems with non-ASCII characters for various reasons. It depends on implementations and other details.

Regular Expressions and Unicode