I am trying to use Obsidian Search to find all notes that meeting the following criteria:
has a property whose key contains “string”; and, 2. has a value that contains “OtherString” within a property that contains “String”
In other words, if I have the following notes with the following properties in my vault:
[[Note A]]
—-
String: OtherString
—-
[[Note B]]
—-
String: null
—-
[[Note C]]
—-
BigString: OtherString
—-
[[Note D]
—-
BigString: OtherStringSmall
—-
[[Note E]]
—-
Sting: OtherString
—-
Then I’d want the search to return only:
[[Note A]]
[[Note C]]
[[Note D]]
Things I have tried
I searched the forums, obsidian.help.md, and reddit.com/r/obsidianmd for “properties regular expression search” and “properties values regular expression search”, and I only found guides to using regular expressions generally.
I searched my Vault for
[/String/]
and got all the notes with properties String and BigString. But when I tried searching for
[/(String)/: /(OtherString)/]
[“/(String)/”: /(OtherString)/]
See if this matches your expectations: [/.*?String/: /OtherString/]
Explanation:
Regular expression mode switched on with pair of / in both key and value places.
.*? in regex layman’s terms means you either have anything before String or not; good for cases where you have word compounds and you want to make a qualifier optional.
Related:
For the value part, /OtherString/, see also this thread with my workaround:
In our current case, though, the closing / had to be applied in both key and value places.
Though Regex is the most precise, you could also try doing line: (String OtherString) which would restrict the search to look at a given line for both strings.