aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorAnton Davydov <antondavydov.o@gmail.com>2015-02-28 13:41:52 +0300
committerAnton Davydov <antondavydov.o@gmail.com>2015-02-28 13:41:52 +0300
commit8005ad3233086ccc21d6dcaa7ba820907601dae1 (patch)
tree1e623fc8ab6dae867427ce9230542916cc8d8525 /activesupport/lib/active_support
parent3458873642182689e835be8643a50b7634c3e0f5 (diff)
downloadrails-8005ad3233086ccc21d6dcaa7ba820907601dae1.tar.gz
rails-8005ad3233086ccc21d6dcaa7ba820907601dae1.tar.bz2
rails-8005ad3233086ccc21d6dcaa7ba820907601dae1.zip
Update documentation examples for String#remove [skip ci]
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/core_ext/string/filters.rb13
1 files changed, 7 insertions, 6 deletions
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, ""