Method: String#remove!

Defined in:
lib/active_support/core_ext/string/filters.rb

#remove!(*patterns) ⇒ Object

Alters the string by removing all occurrences of the patterns.

str = "foo bar test"
str.remove!(" test", /bar/)         # => "foo "
str                                 # => "foo "


39
40
41
42
43
44
45
# File 'lib/active_support/core_ext/string/filters.rb', line 39

def remove!(*patterns)
  patterns.each do |pattern|
    gsub! pattern, ""
  end

  self
end