From: "Gennady F. Bystritsky" Date: 2002-11-26T09:33:05+09:00 Subject: Re: Combining variables and Regex's ----- Original Message ----- From: "Jason Persampieri" To: "ruby-talk ML" Sent: Monday, November 25, 2002 4:27 PM Subject: Combining variables and Regex's > Howdy folks, > > Newbie here... but so far liking what I see. > > My first question is this : > > Is there a shortcut to embed a variable String within > a regex? > > Something like : > myString =~ /$(myVariable)_\d\d\d/ myString =~ /#{myVariable}_\d\d\d/ In general, #{} evaluates a Ruby expression inside string literals. > > instead of > > myString ~= Regexp.new(myVariable + '_\d\d\d') > > > Thanks fellas. > > Jason > > >