My favorite feature of Ruby’s gsub is the ability to pass a block:
"1|2|3".gsub(/\d/) { |m| m.to_i+1 } # => "2|3|4"
This is all kinds of useful.
My favorite feature of Ruby’s gsub is the ability to pass a block:
"1|2|3".gsub(/\d/) { |m| m.to_i+1 } # => "2|3|4"
This is all kinds of useful.