From: nlaveck@... Date: 2016-08-25T02:23:13+00:00 Subject: [ruby-core:77051] [Ruby trunk Bug#12703] String.gsub returns unexpected results with numeric match characters Issue #12703 has been reported by Nathan LaVeck. ---------------------------------------- Bug #12703: String.gsub returns unexpected results with numeric match characters https://bugs.ruby-lang.org/issues/12703 * Author: Nathan LaVeck * Status: Open * Priority: Normal * Assignee: * ruby -v: * Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- I'm unable to prepend a backslash to numeric group matches using gsub ~~~ irb(main):053:0> "z'z".gsub(/(')/, '\\1') => "z'z" ~~~ Expected Result ~~~ => "z\'z" ~~~ Adding an extra backslash gives me this: ~~~ irb(main):056:0> "z'z".gsub(/(')/, '\\\1') => "z\\1z" ~~~ Tested on Ruby version 2.4.0 -- https://bugs.ruby-lang.org/ Unsubscribe: