I have been perusing the documentation for String today, and I saw the :sub method, which I\'d never noticed before. I\'ve been using :gsub
String
:sub
:gsub
value = "abc abc" puts value # abc abc # Sub replaces just the first instance. value = value.sub("abc", "---") puts value # --- abc # Gsub replaces all instances. value = value.gsub("abc", "---") puts value # --- ---