fork download
  1.  
  2. local expr = '--username=John'
  3. local name, value = expr:match( '^%-%-(.*)=%"?(.*)%"?' )
  4. print( "found values for '" .. expr .. "'" )
  5. print( name .. " = " .. value )
  6.  
  7. print( "---------------------------------" )
  8.  
  9. expr = '--username="John Doe"'
  10. name, value = expr:match( '^%-%-(.*)="?(.-)"?$' )
  11. print( "found values for '" .. expr .. "'" )
  12. print( name .. " = " .. value )
  13.  
  14. print( "---------------------------------" )
  15.  
  16. expr = '--username="John Doe"'
  17. name, value = expr:match( '^%-%-(.*)="?([^"]*)"?' )
  18. print( "found values for '" .. expr .. "'" )
  19. print( name .. " = " .. value )
  20.  
Success #stdin #stdout 0s 14120KB
stdin
Standard input is empty
stdout
found values for '--username=John'
username = John
---------------------------------
found values for '--username="John Doe"'
username = John Doe
---------------------------------
found values for '--username="John Doe"'
username = John Doe