Yes the regex example I gave was for the file format I use, but you can tweak it to anything else.
Let’s say a vault has filenames that consist only out of words. Finding notes that don’t have those links requires this regex search:
-/\[\[[a-zA-Z ]+\]\]/
Here inside the pattern we look for any letter from ‘a’ to ‘z’ (a-z), any capital letter ‘A’ to ‘Z’ (A-Z), and possible spaces between words ( ). With the + we don’t care how often those letters and spaces appear, but we require at least one.
Such a pattern matches the following kind of links:
[[a]]
[[mynote]]
[[hello there]]
[[a note with a long title like this one for instance has]]
But of course the pattern also has limitations. It doesn’t match:
-
[[hello-there]] because there’s a dash between the words here.
-
[[2020 my example note]] because this link contains numbers.
-
[[hello there|see this study]] because of the | character.
-
[[my note.md]] because of the dot (.).
-
[[earlier studies, however, contradict]] because of the comma (,).
It’s probably good to have limitations in your pattern (I think so at least) so that you don’t end up matching things you aren’t interested in.
As an experiment we can also make a pattern that is much more flexible. Consider for instance this one:
-/\[\[[a-zA-Z0-9 \-\|\.,]+\]\]/
This search query looks for notes that miss [[...]] links. This time we allow our links to have the following:
- Zero or more lowercased letters (
a-z).
- Zero or more uppercased letters (
A-Z).
- Zero or more digits (
0-9).
- Zero or more spaces (
).
- Zero or more dashes (
\-).
- Zero or more ‘|’ characters (
\|).
- Zero or more periods/dots (
\.).
- And zero or more commas (
,).
Since we have the + again after the pattern, at least one of those 8 possibilities should be between [[ and ]].
With this much more flexible pattern we can have Obsidian look for these links:
[[a]]
[[1]]
[[mynote]]
[[hello there]]
[[a note with a long title like this one for instance has]]
[[hello there|see this study]]
[[my note.md]]
[[earlier studies, however, contradict]]
[[hello-there]]
[[2020 my example note]]
[[2020-06-16 080350]]
Any of these link formats are ‘caught’ by the regex pattern.
I’m always a bit hesitant with very flexible patterns since they might also catch situations we didn’t intend to find.
A good test in Obsidian is to remove the leading - from the query. That way we look for notes that do contain the pattern.
If the search pattern works well, the search query should turn up all the notes of which you know have links. If some of them don’t show up, then the links in those notes aren’t recognised by the pattern.