Hi,
I am new to Ruby. Can I substitute the value of a
variable into a regular expression? For example:
exp = /(\d+)/ #works
exp = /(\d+)/ + 'some string value' #Not!
Thanks,
S
···
__________________________________
Yahoo! Mail Mobile
Take Yahoo! Mail with you! Check email on your mobile phone.
http://mobile.yahoo.com/learn/mail
Yes, the same way you interpolate in strings:
exp = /(\d+)#{'some string value'}/
Hope that helps.
James Edward Gray II
···
On May 17, 2005, at 6:24 PM, Scott Pack wrote:
Hi,
I am new to Ruby. Can I substitute the value of a
variable into a regular expression? For example:
exp = /(\d+)/ #works
exp = /(\d+)/ + 'some string value' #Not!
Scott Pack wrote:
I am new to Ruby. Can I substitute the value of a
variable into a regular expression? For example:
exp = /(\d+)/ #works
exp = /(\d+)/ + 'some string value' #Not!
exp = /(\d+)#{variable}/
but I don’t understand if that’s what you want. Your example doesn’t
agree with your question,
nikolai
···
--
Nikolai Weibull: now available free of charge at http://bitwi.se/\!
Born in Chicago, IL USA; currently residing in Gothenburg, Sweden.
main(){printf(&linux["\021%six\012\0"],(linux)["have"]+"fun"-97);}