Actions
Feature #2778
closedRegular Expression Named Group Matching does not work with String#[]
Status:
Closed
Assignee:
-
Target version:
-
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
Actions
Like0
Like0Like0Like0