From: "alexandre (alexandre borderes) via ruby-core" Date: 2023-07-14T21:24:45+00:00 Subject: [ruby-core:114193] [Ruby master Bug#19769] Range of size 1 in String#tr causes unexpected behavior Issue #19769 has been reported by alexandre (alexandre borderes). ---------------------------------------- Bug #19769: Range of size 1 in String#tr causes unexpected behavior https://bugs.ruby-lang.org/issues/19769 * Author: alexandre (alexandre borderes) * Status: Open * Priority: Normal * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- Hi, I noticed a possible unexpected behavior in String#tr. Is that intentional? ``` ruby 'ABC'.tr 'A-AB', 'XY' # => "YYC" ``` I would expect the same result as: ``` ruby 'ABC'.tr 'AB', 'XY' # => "XYC" ``` The tr utility does exactly that: ``` shell echo ABC | tr A-AB XY # => "XYC" ``` The letter 'A' is interpreted 2 times in that case, shifting by 1 all the replacement string. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/