If you want to have some characters treated literally (if I understood
you properly), try Regexp.quote:
puts a[Regexp.new(Regexp.quote(“G.*#{b}.*rk!”))]
Gennady.
···
On Saturday, February 22, 2003, at 07:35 PM, Mattia Peronio wrote:
I will explain you my problem, with a short example code:
a = “Good this kind of work!”
b = “this kind”
puts a[Regexp.new(“G.*#{b}.rk!“)] >> Good this kind of
work!”
a = “Good this+kind of work!”
b = “this+kind”
puts a[Regexp.new("G.#{b}.*rk!”)] >> nil
I woud like to know if you can implement a method string.to_re which
converts a string to a regular expression, i.e.:
Good this+kind of work >>>> Good this[+]kind of work
Thank you very much for your wonderful Ruby!
Mattia Peronio