module Corefines::String::Remove
@!method remove(*patterns)
Returns a copy of this string with *all* occurrences of the _patterns_ removed. The pattern is typically a +Regexp+; if given as a +String+, any regular expression metacharacters it contains will be interpreted literally, e.g. +'\\d'+ will match a backlash followed by 'd', instead of a digit. @example str = "This is a good day to die" str.remove(" to die") # => "This is a good day" str.remove(/\s*to.*$/) # => "This is a good day" str.remove("to die", /\s*$/) # => "This is a good day" @param *patterns [Regexp, String] patterns to remove from the string. @return [String] a new string.
@!method remove!(*patterns)
Removes all the occurrences of the _patterns_ in place. @see #remove @param *patterns (see #remove) @return [String] self
Public Instance Methods
remove(*patterns)
click to toggle source
# File lib/corefines/string.rb, line 337 def remove(*patterns) dup.remove!(*patterns) end
remove!(*patterns)
click to toggle source
# File lib/corefines/string.rb, line 341 def remove!(*patterns) patterns.each { |pattern| gsub!(pattern, '') } self end