From: Robert Dober Date: 2009-08-21T19:07:27+09:00 Subject: Re: How to convert string "/regexp/i" to /regexp/i - ? On Fri, Aug 21, 2009 at 12:00 PM, Pascal J. Bourguignon wrote: > Joao Silva writes: > >> Fleck Jean-Julien wrote: >>> 2009/8/21 Joao Silva : >>>> >>>> How i can convert this proper way? >>> >>> Try without the quotes >>> >>>>> Regexp.new(/regexp/i) >>> => /regexp/i >>> >>> Cheers, >> >> I cannot do this without quotes - i need get it from string. Only thing >> i have is "/regexp/i" string. > > string="/regexp/i" > Regexp.new(eval(string)) > > > -- > __Pascal Bourguignon__ > Eval is a mighty tool for a tiny task option = str[-1] # Ruby 1.9, use [-1,1] in 1.8 Regexp::new( str[1..-3], option ) HTH R -- module Kernel alias_method :ë, :lambda end