On 2002.05.19, David Alan Black <dblack / candle.superlink.net> wrote:
> Look on the bright side:
> 
>   str = gets
>   matched, x, y = str.match /^\s*(\S+)\s+(\S+)\s*$/
>   if matched
>     puts "You typed the words #{x} and #{y}."
>   else
>     puts "You didn't type two separate words."
>   end
> 
> and such.  The MatchData object really isn't such a bad thing :-)

Hmm.  What does x and y get if the match fails?  I don't have
Ruby 1.7 installed, so I can't just fire up irb and test ...

Also, might this work:

  x, y = str.match /.../ .slice(1..-1)

-- Dossy

-- 
Dossy Shiobara                       mail: dossy / panoptic.com 
Panoptic Computer Network             web: http://www.panoptic.com/ 
  "He realized the fastest way to change is to laugh at your own
    folly -- then you can let go and quickly move on." (p. 70)