Substitution
gsub with patterns.
Replacing Text with sub
String#sub replaces the first match of a pattern with a replacement string. The original string is not changed; a new one is returned.
s = 'hello world'
puts(s.sub(/world/, 'Ruby'))
puts sReplacing All with gsub
gsub means global substitution. It replaces every match, not just the first.
puts('a-b-c-d'.gsub(/-/, '_'))
puts('one two two'.gsub(/two/, 'three'))