regex - Basic Matching in Ruby -
i working through book , gives example x = "this test".match(/(\w+) (\w+)/) we looking @ parentheses , being able access passed separately. when put expression above irb get: matchdata "this is" 1:"this" 2:"is"> why doesn't include a , test ? would have include .match(/(\w+) (\w+) (\w+) (\w+)/) ? the 'match' method not matching regex globally. returning first match. can use 'scan' method rather 'match' , should return array of matches of regex. [~]$ irb 1.8.7-p371 :001 > x = "this test".match(/(\w+) (\w+)/) => #<matchdata "this is" 1:"this" 2:"is"> 1.8.7-p371 :002 > x = "this test".scan(/(\w+) (\w+)/) => [["this", "is"], ["a", "test"]]