R
Ruby Newbee
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.
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.