Substitute something within a string for something else.
puts "foobar".sub('bar', 'foo')
Here, string sub method substitutes the first instance of the first parameter 'bar' with the second parameter 'foo'.
sub method does one substitution at a time on the first instance of the text to match.
String gsub method does multiple substitutions at once:
puts "this is a test".gsub('i', 'I')