From: Robert Klemme Date: 2009-09-08T00:19:30+09:00 Subject: Re: How to convert a "normal" searchstring into regexp 2009/9/7 Fabian Streitel : > this seems to do the trick: > http://pastie.org/608326 > I haven't tested it much though... A simple solution: class String def to_glob Regexp.new(gsub(%r{(? "\\.", "*" => ".*", "?" => "." } end irb(main):015:0> "foo*.b?r".to_glob => /foo.*\.b.r/ Of course, this is not complete, as other regexp meta characters need to be dealt with. And you need 1.8.7 or 1.9.* for the negative lookbehind to work IIRC. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/