I'd like to do something like:
s,e = string.find(str, pattern1) or string.find(str, pattern2)
(because lua patterns don't have the equivalent of a regex |)
But this gives me nil for e even if one of the patterns matches.
How can I get both return values from the first function call to match?
Both of your function calls are neither the only nor the last one in a list of expressions. Hence their list of return values is adjusted to 1 value.
See https://www.lua.org/manual/5.4/manual.html#3.4
hence
is more or less equivalent to
Assuming the first pattern matches, then
v1is a true value. Theorstatement is being short-circuited so you assignIf the first pattern does not match the second string.find is called. If there's a match it's return value is a true value
If the first pattern does not match and the second does not match you assign
You need to handle both string.find calls separately in order to not lose any return values.