Method: String#-
- Defined in:
- lib/core/facets/string/remove.rb
#-(pattern) ⇒ Object
Removes occurances of a string or regexp. This is an operator form for the #remove method.
("HELLO HELLO" - "LL") #=> "HEO HEO"
("HELLO PERL" - /L\S/) #=> "HEO PERL"
Returns a new [String] with all pattern matches removed.
CREDIT: Benjamin David Oakes
26 27 28 |
# File 'lib/core/facets/string/remove.rb', line 26 def -(pattern) gsub(pattern, '') end |