From a2aa1d434a5fe9a703eccb99d1a4a994bc4f5df4 Mon Sep 17 00:00:00 2001 From: Rashmi Yadav Date: Wed, 14 Aug 2013 21:32:22 +0200 Subject: Added docs for 'remove' method [ci skip] --- guides/source/active_support_core_extensions.md | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'guides') diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md index 1915252122..fade836873 100644 --- a/guides/source/active_support_core_extensions.md +++ b/guides/source/active_support_core_extensions.md @@ -1249,6 +1249,17 @@ Calling `to_s` on a safe string returns a safe string, but coercion with `to_str Calling `dup` or `clone` on safe strings yields safe strings. +### `remove` + +The method `remove` will remove all occurrences of the pattern: + +```ruby +"Hello World".remove(/Hello /) => "World" +``` + +There's also the destructive version `String#remove!`. + +NOTE: Defined in `active_support/core_ext/string/filters.rb`. ### `squish` The method `squish` strips leading and trailing whitespace, and substitutes runs of whitespace with a single space each: -- cgit v1.2.3