I am having problems with named regular expression captures in Ruby 2.0. I have a string variable and an interpolated regular expression:
str = "hello world"
re = /\w+/
/(?<greeting>
greeting
This throws the following exception:
prova.rb: 4: in <main>': undefined local variable or methodgreeting 'for main: Object (NameError)
shell returned 1
However, the interpolated expression works without named captures. For instance:
/(
$1
source
share