From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id F3A1F19E0056 for ; Wed, 9 Dec 2015 14:55:16 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id 5108FB5D8E2 for ; Wed, 9 Dec 2015 15:26:59 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id DAA0918CC7B1 for ; Wed, 9 Dec 2015 15:26:59 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id AFACC1205C7; Wed, 9 Dec 2015 15:26:58 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o10.shared.sendgrid.net (o10.shared.sendgrid.net [173.193.132.135]) by neon.ruby-lang.org (Postfix) with ESMTPS id CC1871205AD for ; Wed, 9 Dec 2015 15:26:53 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=dWPLQgSwKB6AKtnneuhpLV1BPyQ=; b=LzmSnMMR8eNrvAuJBz Z/vubrZuGx83cK+niWzurDluM0wB5b11rfJPgs3v4yLL6Q3bzgKs6Ii4buYv930w BokKl7jWXzrIR9R7H4FTvJh0CVFTkY+nSNwDC/5OdrgTzT3+t23W/6hIH+RCL735 3vGwQcJ1CFmJ0t66GCqQIo2H4= Received: by filter0498p1mdw1.sendgrid.net with SMTP id filter0498p1mdw1.30286.5667C9AAE 2015-12-09 06:26:50.162572957 +0000 UTC Received: from herokuapp.com (ec2-54-90-77-238.compute-1.amazonaws.com [54.90.77.238]) by ismtpd0001p1iad1.sendgrid.net (SG) with ESMTP id 0-a867OORiG_VvzCuY_z-w for ; Wed, 09 Dec 2015 06:26:50.627 +0000 (UTC) Date: Wed, 09 Dec 2015 06:26:50 +0000 From: matthew@kerwin.net.au To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Redmine-MailingListIntegration-Message-Ids: 46689 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11793 X-Redmine-Issue-Author: burnson X-Redmine-Sender: phluid61 X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS771V4vcgud7heBaCDcoHkaz6MFTmEms1lap5 GnVaO+WDTUTsdhDW59qYq2HPpDo15jMG5TCjDrF7eXofka0FczjlA8Z1+VKy3v3ydwLab3HJYsJjOj jJVKrI+lNIiZpiCsyGkmYSR5dbSw1UsqLXAffB7G3cRo4iVltde2Oix69Q== X-ML-Name: ruby-core X-Mail-Count: 71986 Subject: [ruby-core:71986] [Ruby trunk - Bug #11793] puts 'ab'.gsub('a', '\\+') - unexpected output X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #11793 has been updated by Matthew Kerwin. I should have used this example: ~~~ puts 'ab'.gsub('a', "\x5C\x5C\x2B") \+b ~~~ ---------------------------------------- Bug #11793: puts 'ab'.gsub('a', '\\+') - unexpected output https://bugs.ruby-lang.org/issues/11793#change-55395 * Author: William Burnson * Status: Rejected * 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/