From: Ruby Luva Date: 2009-05-15T22:11:03+09:00 Subject: Re: String Indexing Pascal J. Bourguignon wrote: > Ruby Luva writes: > one=123 yeah! > two=yes yes Hi, thanks for the great, simple solution!! The problem for me is that I do not know what the second value I am looking for is... :) I am making an HTTP request to a site and I know one value to look for. The value I am interested in changes but is always 2 lines above the string I CAN find. This code works: #if I want to retrieve 'a' data = ['a','b','c'] found = data.index('c') puts data[found-2] Sadly I need it to work on a HTTP request so I store my data liek this: got = Array.new go = net::HTTP.new(a,b) ... got = go.get('some_path') ... i = got.index('some known string') puts got[i-2] #print the secret string 2 lines above In theory in my mind I can make it work, but in code, I can't/ I get an error: undefined method `index' for # (NoMethodError) Thanks for spending time looking at my post. -- Posted via http://www.ruby-forum.com/.