local expr = '--username=John' local name, value = expr:match( '^%-%-(.*)=%"?(.*)%"?' ) print( "found values for '" .. expr .. "'" ) print( name .. " = " .. value ) print( "---------------------------------" ) expr = '--username="John Doe"' name, value = expr:match( '^%-%-(.*)="?(.-)"?$' ) print( "found values for '" .. expr .. "'" ) print( name .. " = " .. value ) print( "---------------------------------" ) expr = '--username="John Doe"' name, value = expr:match( '^%-%-(.*)="?([^"]*)"?' ) print( "found values for '" .. expr .. "'" ) print( name .. " = " .. value )