I’m trying to create a filter rule in bases that will loop through list entries in files and compare each of them to a string. property.contains() however only returns true if a list entry is an exact match. So it checks if the list contains the string, rather than whether any entry contains the string. An example:
Objective:
Find notes that have “John Doe” in their persons property(list) by searching only for “John” or “Doe”.
Problem:
Right now, I need to compare to the full string “John Doe” to get a match.
This is also true for lists of links (not just text). So [[John Doe | John]] will also only produce a match if the filter string is “John Doe”. “John” won’t suffice.
Things I have tried
I checked the list part of the bases documentation and couldn’t find anything pointing me in the right direction.
Or use the first version but also make sure that yourSearchTerm is the same item type as the item you’re looking for.
Explanation…
When used on a string, the contains function looks in the string for substrings. That’s the one you’re trying to do.
When used on a list, the contains function looks in the list for list items, which are whole things unto themselves, be they links, dates, numbers, strings, or whatever. The function someList.contains() is not for parsing into portions of the list item.
Assuming they’re the same function is very understandable! The docs describe string.contains() and list.contains() as two different functions, but it’s still probably not very clear to everyone.