Issue #8343 has been reported by rkh (Konstantin Haase).

----------------------------------------
Feature #8343: StringScanner#[] should accept names of named captures
https://bugs.ruby-lang.org/issues/8343

Author: rkh (Konstantin Haase)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 


Example:

    s = StringScanner.new("Fri Dec 12 1975 14:39")
    s.scan(/(?<wday>\w+) (?<month>\w+) (?<day>\d+) /)

    # this currently works
    s[0]                               # -> "Fri Dec 12 "
    s[1]                               # -> "Fri"
    s[2]                               # -> "Dec"
    s[3]                               # -> "12"

    # this currently does not work
    s[:wday]                           # -> "Fri"
    s[:month]                          # -> "Dec"
    s[:day]                            # -> "12"

I attached a patch including tests for MRI, I don't know if Rubinius has a different implementation, I guess JRuby has.
I can look into this if the feature gets accepted.


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