Peter Szinek wrote:

> Hello,
> 
> I need to match a chunk of code like this:
> 
> ...
> ...
> #begin here
> ..}
> .....end
> ..}
> .....}
> ....end

This won't solve the entire problem, but it will give you an array of
indices to matching elements:

---------------------------------

#!/usr/bin/ruby -w

data = File.read("testdata.txt")

match_indices = []

data.scan(/\}/) do
  match_indices << Regexp.last_match.begin(0)
end

puts match_indices

---------------------------------

You could begin by scanning to your planned start mark, then scan for
matching elements using this code. Or you could segregate the block between
the start and end marks, then scan for matches in the substring using this
code.

-- 
Paul Lutus
http://www.arachnoid.com