Issue #4650 has been updated by Nobuyoshi Nakada.


It's spec.

Cited from doc/re.rdoc:

  *Note*: A regexp can't use named backreferences and numbered
  backreferences simultaneously.


----------------------------------------
Bug #4650: sub/gsub with named group captures discards numbered group captures
http://redmine.ruby-lang.org/issues/4650

Author: NoƩ Rubinstein
Status: Open
Priority: Normal
Assignee: 
Category: core
Target version: 
ruby -v: ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux]


puts "ab".sub(/(?<g>.)(.)/, "0=\\0 1=\\1 2=\\2 g=\\k<g>") # outputs "0=ab 1= 2= g=a"

Expected: "0=ab 1=b 2= g=a"
(or maybe "0=ab 1= 2=b g=a"? Though I think it's the former)



-- 
http://redmine.ruby-lang.org