From: franklsf95@... Date: 2014-07-10T00:39:36+00:00 Subject: [ruby-core:63616] [ruby-trunk - Bug #10022] [Open] Inconsistent behavior of gsub replacement Issue #10022 has been reported by Frank Luan. ---------------------------------------- Bug #10022: Inconsistent behavior of gsub replacement https://bugs.ruby-lang.org/issues/10022 * Author: Frank Luan * Status: Open * Priority: Normal * Assignee: * Category: regexp * Target version: * ruby -v: ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN ---------------------------------------- In the following code, the two gsub's yield different results. ([[https://gist.github.com/franklsf95/6c0f8938f28706b5644d]]) ~~~ ver = 9999 str = "\tCFBundleDevelopmentRegion\n\ten\n\tCFBundleVersion\n\t0.1.190\n\tAppID\n\t000000000000000" puts str.gsub /(CFBundleVersion<\/key>\n\t.*\.).*(<\/string>)/, "#{$1}#{ver}#{$2}" puts '--------' puts str.gsub /(CFBundleVersion<\/key>\n\t.*\.).*(<\/string>)/, "#{$1}#{ver}#{$2}" ~~~ My running result is: ~~~ CFBundleDevelopmentRegion en 9999 AppID 000000000000000 -------- CFBundleDevelopmentRegion en CFBundleVersion 0.1.9999 AppID 000000000000000 ~~~ ...which is strangely inconsistent. -- https://bugs.ruby-lang.org/