On Sun, Dec 7, 2008 at 12:08 PM, Robert Klemme
<shortcutter / googlemail.com> wrote:
> On 06.12.2008 14:30, Robert Dober wrote:
>>
>> On Sat, Dec 6, 2008 at 2:06 PM, Michael Fellinger <m.fellinger / gmail.com>
>> wrote:
>>>>
>>>> File::read("test.data").scan  %r{Hello.{0,10}World}im
>>>
>>> That would be 10 characters
>>
>> Huh??
>
> I guess Michael's point was that your version is not a scaled down version
> of mine because it defines "proximity" differently: your version uses
> character count while my version uses word count.
Use words, I see, if one uses words I can understand that ;)

Actually I was just wondering if we should not keep track of the
positions we found, what good would a search do if we cannot go there
:(.
>
> Another difference is that in your case order matters.  Here's an attempt to
Does it not? Hmm right in a search engine it indeed does not, agreed...
> fix both:
>
> # untested
> s.scan %r{
>  \b
>  (?:
>      hello\W+(?:\w+\W+){0,10}world
>  |   world\W+(?:\w+\W+){0,10}hello
>  )
>  \b
> }mix

r = []
s.scan( your stuff ) do |m| r << [$`.size, m] end
r

R