Project

General

Profile

Bug #10518

String "delete" method does not remove some characters from input string

Added by sergio.gallelli (Sergio Gallelli) over 5 years ago. Updated over 5 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.1.4p265 (2014-10-27 revision 48166) [i386-mingw32]
[ruby-core:66317]

Description

This bug affects all Ruby versions I tried, i.e. 2.0.0 and 2.1.4 on Windows and 2.1.5 on Linux
In some cases the String "delete" method does not remove all the characters from the input string I ask for removal.
The problem seems to depend on the string passed as argument to the delete method and on the order of its characters.
Please take a look at the simple "irb" dump below:

irb(main):001:0> str = 'A-B'
=> "A-B"
irb(main):002:0> str.delete ' -#'
=> "A-B"
irb(main):003:0> str.delete ' #-'
=> "AB"

If I try to remove the dash from string 'A-B' passing ' -#' to the delete method, it does not work.
If I change the order of the characters passed to the delete method, the result is correct.
The attached Ruby program shows the above problem.


Files

str_delete_bug.rb (59 Bytes) str_delete_bug.rb sergio.gallelli (Sergio Gallelli), 11/16/2014 11:15 AM

Also available in: Atom PDF