From: Stefan Rusterholz Date: 2008-12-06T22:55:27+09:00 Subject: Re: Proximity searches in Ruby Robert Dober wrote: > File::read("test.data").scan %r{Hello.{0,10}World}im Another nice idea. And another mainly untested improvement: module StringProximitySearch def proximity_search(w1, w2, distance=0) self =~ %r{#{Regexp.escape(w1)}\W+(?:\w+\W+){0,#{distance}}#{Regexp.escape(w2)}}im end end Regards Stefan -- Posted via http://www.ruby-forum.com/.