First of all this doesn't match ok or capture "ok".find("(ok|capture)") -- nil
Second, followed by ok match an optional ok;args but only capture args as parameter. This is wrong "ok;args".find("(ok)(;.+)?"), and capture group includes extra ;.
function mymatch(str)
local _, _, ok, oreveal = str:find("(ok)")
return ok, oreveal
end
-- this is what I want
print(mymatch("ok")) -- ok nil
print(mymatch("cancel")) -- cancel nil
print(mymatch("ok;domatch")) -- ok domatch
print(mymatch("okdontmatch")) -- nil nil