< :前の番号
^ :番号順リスト
> :次の番号
P :前の記事(スレッド移動)
N :次の記事(スレッド移動)
|<:前のスレッド
>|:次のスレッド
^ :返事先
_:自分への返事
>:同じ返事先を持つ記事(前)
<:同じ返事先を持つ記事(後)
---:分割してスレッド表示、再表示
| :分割して(縦)スレッド表示、再表示
~ :スレッドのフレーム消去
.:インデックス
..:インデックスのインデックス
Issue #9457 has been updated by Akira Tanaka.
Status changed from Open to Rejected
I think it is not a bug.
The subexpression, (Tarzan|Jane), matches twice: "Tarzan" and "Jane".
So the last matched string, "Jane", is recorded in the match object.
Consider following.
% ruby -e 'p /((Tarzan|Jane)) loves (\g<2>)/.match("Tarzan loves Jane")'
#<MatchData "Tarzan loves Jane" 1:"Tarzan" 2:"Jane" 3:"Jane">
% ruby -e 'p /(?<subj>(?<name>Tarzan|Jane)) loves (?<obj>\g<name>)/.match("Tarzan loves Jane")'
#<MatchData "Tarzan loves Jane" subj:"Tarzan" name:"Jane" obj:"Jane">
----------------------------------------
Bug #9457: Regexp: when using subexpression calls, returned match groups seem wrong
https://bugs.ruby-lang.org/issues/9457#change-44656
* Author: David Stosik
* Status: Rejected
* Priority: Normal
* Assignee:
* Category: regexp
* Target version:
* ruby -v: ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]
* Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
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
--
http://bugs.ruby-lang.org/