From 8005ad3233086ccc21d6dcaa7ba820907601dae1 Mon Sep 17 00:00:00 2001 From: Anton Davydov Date: Sat, 28 Feb 2015 13:41:52 +0300 Subject: Update documentation examples for String#remove [skip ci] --- activesupport/lib/active_support/core_ext/string/filters.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'activesupport/lib/active_support') diff --git a/activesupport/lib/active_support/core_ext/string/filters.rb b/activesupport/lib/active_support/core_ext/string/filters.rb index b88976eab2..a777044d30 100644 --- a/activesupport/lib/active_support/core_ext/string/filters.rb +++ b/activesupport/lib/active_support/core_ext/string/filters.rb @@ -24,17 +24,18 @@ class String end # Returns a new string with all occurrences of the patterns removed. - # str = "foo bar test" - # str.remove(" test") # => "foo bar" - # str # => "foo bar test" + # str = "foo bar test baz" + # str.remove(" test baz") # => "foo bar" + # str.remove(" test ", /baz/) # => "foo bar" + # str # => "foo bar test baz" def remove(*patterns) dup.remove!(*patterns) end # Alters the string by removing all occurrences of the patterns. - # str = "foo bar test" - # str.remove!(" test") # => "foo bar" - # str # => "foo bar" + # str = "foo bar test baz" + # str.remove!(" test ", /baz/) # => "foo bar" + # str # => "foo bar" def remove!(*patterns) patterns.each do |pattern| gsub! pattern, "" -- cgit v1.2.3