From: mame@ruby-lang.org
To: ruby-core@ruby-lang.org
Subject: [ruby-core:99531] [Ruby master Bug#17110] String.tr unexpected behaviour with backslash
Date: Mon, 10 Aug 2020 05:35:30 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-86991.20200810053529.42821@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-17110.20200810030009.42821@ruby-lang.org
Issue #17110 has been updated by mame (Yusuke Endoh).
Status changed from Open to Rejected
See the document.
> The backslash character `\` can be used to escape `^` or `-` and is otherwise ignored unless it appears at the end of a range or the end of the from_str or to_str:
https://docs.ruby-lang.org/en/2.7.0/String.html#method-i-tr
So you can write `"\\".tr("C\\", "BA")` according to the document.
This seems undocumented, but `\` can be used to escape `\`, so you can also write `"\\".tr("\\\\C", "AN")`.
----------------------------------------
Bug #17110: String.tr unexpected behaviour with backslash
https://bugs.ruby-lang.org/issues/17110#change-86991
* Author: theplen (Joey Sheets)
* Status: Rejected
* Priority: Normal
* ruby -v: ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x64-mingw32]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
`"\\".tr("\\","A")` works great, with `"\\"` becoming `"A"`.
`"\\".tr("\\C","AB")` should also output `"A"`, but instead outputs `"\\"`.
--
https://bugs.ruby-lang.org/
next prev parent reply other threads:[~2020-08-10 5:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-10 3:00 [ruby-core:99528] [Ruby master Bug#17110] String.tr unexpected behaviour with backslash entpman
2020-08-10 3:01 ` [ruby-core:99529] " entpman
2020-08-10 5:35 ` mame [this message]
2020-08-10 7:09 ` [ruby-core:99533] " entpman
2020-08-10 8:18 ` [ruby-core:99535] " mame
2020-08-10 14:51 ` [ruby-core:99543] " entpman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-86991.20200810053529.42821@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).