----- Original Message ----- 
From: "Jason Persampieri" <jason / persampieri.net>
To: "ruby-talk ML" <ruby-talk / ruby-lang.org>
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
> 
> 
>