Simple Substitution with Block
If a block is provided to sub or gsub then the matched string is passed onto the block and the return value of the block is used to do the replacement.
"Superman".gsub(/[aeiou]/) {|m| m.upcase }# => "SUpErmAn"
If a block is provided to sub or gsub then the matched string is passed onto the block and the return value of the block is used to do the replacement.
"Superman".gsub(/[aeiou]/) {|m| m.upcase }# => "SUpErmAn"