Rebhan, Gilbert wrote:
> Hi,
> 
> i have a txtfile like that =
> 
> bla1
> foo=red
> 
> bla2
> foo=green
> 
> bla3
> foo=yellow
> 
> and i want to get i.e. bla1 and the corresponding value of foo
> 
> i tried with 
> 
> File.open("Y:/test/sample.txt", "r").each do |line|
>   puts $1<<' : '<< $3 if line =~ /(\w+)\s+(\w+=)(\w+)/
> end
> 
> but somehow the regex doesn't work ?!
> whereas it works in the QuickRex Plugin for Eclipse

Well... for each line of the file you are trying to match 2 lines. 
That's impossible :). Read the file in "paragraph mode" and match each 
paragraph, or read it whole and scan it for your regexp.

For example (not tested):

File.read('...').scan(/^(\w+)\s*\n\w+=(\w+)$/) {|a,b| puts a+": "+b}

Good luck.
--