ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: william.burnson@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:71979] [Ruby trunk - Bug #11793] puts 'ab'.gsub('a', '\\+') - unexpected output
Date: Wed, 09 Dec 2015 05:33:58 +0000	[thread overview]
Message-ID: <redmine.journal-55387.20151209053358.ff5c5dda9535d96c@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-11793.20151209053122@ruby-lang.org

Issue #11793 has been updated by William Burnson.

Description updated

----------------------------------------
Bug #11793: puts 'ab'.gsub('a', '\\+') - unexpected output
https://bugs.ruby-lang.org/issues/11793#change-55387

* Author: William Burnson
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin15]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
Test case:
puts 'ab'.gsub('a', '\\\\+')

Expected output:
\\+b

Actual output:
b

The way I understand gsub(pattern, replacement) when used with two string arguments is that it will perform a literal replacement, so it is quite unexpected that substituting with \+ removes the pattern entirely.

Doc: http://ruby-doc.org/core-2.2.3/String.html#method-i-gsub



-- 
https://bugs.ruby-lang.org/

  parent reply	other threads:[~2015-12-09  5:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-11793.20151209053122@ruby-lang.org>
2015-12-09  5:31 ` [ruby-core:71976] [Ruby trunk - Bug #11793] [Open] puts 'ab'.gsub('a', '\\+') - unexpected output william.burnson
2015-12-09  5:32 ` [ruby-core:71977] [Ruby trunk - Bug #11793] " william.burnson
2015-12-09  5:32 ` [ruby-core:71978] " william.burnson
2015-12-09  5:33 ` william.burnson [this message]
2015-12-09  5:34 ` [ruby-core:71980] " william.burnson
2015-12-09  6:16 ` [ruby-core:71982] " hanmac
2015-12-09  6:18 ` [ruby-core:71983] [Ruby trunk - Bug #11793] [Rejected] " usa
2015-12-09  6:23 ` [ruby-core:71984] [Ruby trunk - Bug #11793] " matthew
2015-12-09  6:26 ` [ruby-core:71986] " matthew
2015-12-09  6:31 ` [ruby-core:71987] " nobu

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-55387.20151209053358.ff5c5dda9535d96c@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).