From: joe chesak Date: 2010-01-04T17:16:31+09:00 Subject: Re: how to capture all conditions using regex --0016364c78fd8e7f3b047c5256f2 Content-Type: text/plain; charset=ISO-8859-1 The regex itself seems okay... irb(main):015:0> x.scan(/\d{3}/) => ["123", "456", "789"] On Mon, Jan 4, 2010 at 8:53 AM, Ruby Newbee wrote: > Hello, > > irb(main):001:0> x="123 456 789" > => "123 456 789" > > irb(main):003:0> if /\d{3}/ =~ x > irb(main):004:1> puts $& > irb(main):005:1> end > 123 > > > For the statement above, I want to capture all "123" and "456" and > "789", not the only "123". > How to do it (must use regex)? Thanks. > > --0016364c78fd8e7f3b047c5256f2--