a = b or c means: if b is undefined i. e. b = nil, then a = c
At the time the original posting was written matches would have been undefined if capture group #2 was empty.
Today, this behaviour has been changed. All capture groups in the regex will be defined and empty capture groups will contain an empty string i.e. "". When the original post was written a script like send( matches ) would have caused a Lua error whenever capture group #2 was empty.
Code: Select all
t = "hello"
send( matches or t )
sent the default value "hello" in case matches was empty. That was the whole point of the expression. Today, it's meaningless in this respect. Today you can make good use for this sort of expression when initializing variables e.g.
-> if c is undefined at the time this script is run, initialize it to 0 instead of causing a Lua runtime error.