I am using the string.find
function but finding an unexpected output when checking if it returns nil
. However, it seems to work if I use string.match
. I am new to Lua so just wondering if this is expected behaviour, and if so, why?
${nil == nil}
returnstrue
${string.find("a", "b")}
returnsnil
${string.match("a", "b")}
returns `nil${string.match("a", "b") == nil}
returnstrue
but…${string.find("a", "b") == nil}
returnsfalse
!
Am I doing something wrong?
For context, I am trying to write a query that finds all tasks containing a certain string but it just outputs all tasks instead:
${query[[
from index.tag "task"
where string.find(name, "instalment") ~= nil
]]}
However, the same query with string.match
works fine:
${query[[
from index.tag "task"
where string.match(name, "instalment") ~= nil
]]}
Thanks in advance!