StringScanner# should accept names of named captures
s = StringScanner.new("Fri Dec 12 1975 14:39") s.scan(/(?<wday>\w+) (?<month>\w+) (?<day>\d+) /) # this currently works s # -> "Fri Dec 12 " s # -> "Fri" s # -> "Dec" s # -> "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.
- ext/strscan/strscan.c (strscan_aref): support named captures. patched by Konstantin Haase [ruby-core:54664] [Feature #8343]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Updated by naruse (Yui NARUSE) over 6 years ago
- 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.