I want to parse user input using named captures for readability.
When they type a command I want to capture some params and pass them. I\'m using RegExps in a case s
This is ugly but works for me in Ruby 1.9.3:
while command != "quit" print "Command: " command = gets.chomp case command when /load (?\w+)/ load($~[:filename]) end end
Alternatively you can use the English extension of $~, $LAST_MATCH_INFO.
$~
$LAST_MATCH_INFO