Project

General

Profile

Actions

Bug #4650

closed

sub/gsub with named group captures discards numbered group captures

Added by Phlogistique (Noé Rubinstein) almost 13 years ago. Updated almost 13 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux]
Backport:
[ruby-core:36023]

Description

puts "ab".sub(/(?.)(.)/, "0=\0 1=\1 2=\2 g=\k") # 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)

Updated by nobu (Nobuyoshi Nakada) almost 13 years ago

It's spec.

Cited from doc/re.rdoc:

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

Updated by nobu (Nobuyoshi Nakada) almost 13 years ago

  • Status changed from Open to Rejected
Actions

Also available in: Atom PDF

Like0
Like0Like0