Project

General

Profile

Actions

Feature #2778

closed

Regular Expression Named Group Matching does not work with String#[]

Added by rklemme (Robert Klemme) almost 15 years ago. Updated over 13 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:28290]

Description

=begin
I just noticed this:

irb(main):001:0> s = "Robert Klemme"
=> "Robert Klemme"
irb(main):002:0> s[/(?\w+)\s+\w+/, :first]
TypeError: can't convert Symbol into Integer
from (irb):2:in []' from (irb):2 from /opt/bin/irb19:12:in '
irb(main):003:0> s.match(/(?\w+)\s+\w+/)[:first]
=> "Robert"

IMHO it's just a small glitch but I believe for consistency reasons we should allow for a symbol as second argument with String#[] as well.
=end


Related issues 1 (0 open1 closed)

Is duplicate of Ruby master - Feature #966: String#[] should accept (Regexp, String) args so named groups can be usedClosedakr (Akira Tanaka)01/02/2009Actions
Actions #1

Updated by naruse (Yui NARUSE) almost 15 years ago

  • Status changed from Open to Closed

=begin
This will be implemented in Ruby 1.9.2.
=end

Actions #2

Updated by rklemme (Robert Klemme) almost 15 years ago

=begin
Thanks for the update! I wonder whether closing is the proper resolution. Shouldn't we be setting target version to 1.9.2 and keep this open until the code change is done?
=end

Actions #3

Updated by naruse (Yui NARUSE) almost 15 years ago

=begin
"will" means 1.9.2 is not released yet; the code is already in trunk.
see also #966
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0