I think "multiple patterns and custom logic" here means usage like this:
string.match('123', '12(%d+)') or string.match('123', '(%d+)')
Since or
is short-circuit, if the first pattern matches, it will be the value of the expresion, otherwise the second pattern will try to match. This is exactly the regex (12)?(%d+)
means.
Also note that there are more powerful LPeg or other regex libraries for Lua.