Project

General

Profile

Actions

Bug #9457

closed

Regexp: when using subexpression calls, returned match groups seem wrong

Added by dstosik (David Stosik) almost 11 years ago. Updated almost 11 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]
[ruby-core:60168]

Description

Hello,

Here are a two examples:

/(Tarzan|Jane) loves (\g<1>)/.match("Tarzan loves Jane").to_a
#=> ["Tarzan loves Jane", "Jane", "Jane"]
# Expected: ["Tarzan loves Jane", "Tarzan", "Jane"]

(http://rubular.com/r/We2x4XNB2l)

/(?<name>(Tarzan|Jane)) loves (\g<name>)/.match("Tarzan loves Jane").to_a
#=> ["Tarzan loves Jane", "Jane"]
# Expected: ["Tarzan loves Jane", "Tarzan", "Jane"]

(http://rubular.com/r/1e3oevc1Yg)

Unless I'm wrong on the results I'm expecting, I think this is a bug.

Thanks for your help,

David

Actions

Also available in: Atom PDF

Like0
Like0Like1