Project

General

Profile

Actions

Bug #19769

closed

Range of size 1 in String#tr causes unexpected behavior

Added by alexandre (alexandre borderes) 10 months ago. Updated 10 months ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:114193]

Description

Hi,

I noticed a possible unexpected behavior in String#tr.
Is that intentional?

'ABC'.tr 'A-AB', 'XY'   # => "YYC"

I would expect the same result as:

'ABC'.tr 'AB', 'XY'     # => "XYC"

The tr utility does exactly that:

echo ABC | tr A-AB XY   # => "XYC"

The letter 'A' is interpreted 2 times in that case, shifting by 1 all the replacement string.

(I found this related https://bugs.ruby-lang.org/issues/1953)

Actions #2

Updated by Anonymous 10 months ago

  • Status changed from Open to Closed

Applied in changeset git|e5825de7c9f07e4f7bd2b83ce8973e19a4652916.


[Bug #19769] Fix range of size 1 in String#tr

Actions

Also available in: Atom PDF

Like0
Like0Like0