From: "naruse (Yui NARUSE)" Date: 2013-04-30T17:27:31+09:00 Subject: [ruby-core:54713] [CommonRuby - Feature #8343][Assigned] StringScanner#[] should accept names of named captures Issue #8343 has been updated by naruse (Yui NARUSE). Status changed from Open to Assigned Assignee set to naruse (Yui NARUSE) rkh (Konstantin Haase) wrote: > On a related note: should the patch be submitted in a second issue on the ruby-trunk project? Here is also correct place now. I'll merge this if there are no objection. ---------------------------------------- Feature #8343: StringScanner#[] should accept names of named captures https://bugs.ruby-lang.org/issues/8343#change-39059 Author: rkh (Konstantin Haase) Status: Assigned Priority: Normal Assignee: naruse (Yui NARUSE) Category: Target version: Example: s = StringScanner.new("Fri Dec 12 1975 14:39") s.scan(/(?\w+) (?\w+) (?\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/