Misc #12730
closedDocumentation String.slice!(regex)
Description
at http://ruby-doc.org/core-2.2.0/String.html#method-i-slice-21
In the example
string = "this is a string"
string.slice!(/s.*t/)   #=> "sa st"
When ran in irb the result is different than shown because the regex starts at the first s and then ends at the last t.
in irb
2.3.0 :001 > string = "this is a string"
=> "this is a string"
2.3.0 :002 > string.slice!(/s.*t/)
=> "s is a st"
the documentation should be:
string.slice!(/s.*t/) #=> "s is a st"
        
           Updated by cody-soultz (Cody Soultz) about 9 years ago
          Updated by cody-soultz (Cody Soultz) about 9 years ago
          
          
        
        
      
      - Subject changed from Documentation String.splice(regex) to Documentation String.slice!(regex)
        
           Updated by cody-soultz (Cody Soultz) about 9 years ago
          Updated by cody-soultz (Cody Soultz) about 9 years ago
          
          
        
        
      
      James Britt Pointed out to me that:
The example in the docs shows a sequence of operations on the same string instance. "slice!" will modify the receiver, so the next operation is working on a changed string.
Your example doesn't match what is happening in the docs, so the results are different. In the docs example there are two previous calls to "slice!"
So this issue should now be closed. I do not see how to close this...sorry
        
           Updated by hsbt (Hiroshi SHIBATA) about 9 years ago
          Updated by hsbt (Hiroshi SHIBATA) about 9 years ago
          
          
        
        
      
      - Status changed from Open to Rejected