I think it’s the input, my value for number_range does not have the
{…}:
question = "A {30-45} year old {asthmatic, diabetic, hypertensive}
{male,
.4} presents with blurry vision in the {left} eye. … "
number_range = ‘30-45’
new_num = ‘42’
puts question.gsub!(/{#{number_range}}/, new_num) => A 42 year old
{asthmatic, diabetic, hypertensive} {male, .4} presents with blurry
vision
in the {left} eye. …
Pattern matching sets some global variables :
$~ is equivalent to ::last_match;
$& contains the complete matched text;
$` contains string before match;
$’ contains string after match;
$1, $2 and so on contain text matching first, second, etc capture group;
$+ contains last capture group.
Pattern matching sets some global variables :
$~ is equivalent to ::last_match;
$& contains the complete matched text;
$` contains string before match;
$’ contains string after match;
$1, $2 and so on contain text matching first, second, etc capture group;
$+ contains last capture group.
Pattern matching sets some global variables :
$~ is equivalent to ::last_match;
$& contains the complete matched text;
$` contains string before match;
$’ contains string after match;
$1, $2 and so on contain text matching first, second, etc capture group;
Thank you - thats a huge help!
There is one important thing you should know: these global variables
are not really global. They are per thread and per scope.