From: Robert Klemme Date: 2013-01-21T01:10:39+09:00 Subject: Re: match a value from hash which is inside array On Sun, Jan 20, 2013 at 3:27 PM, robert lengu wrote: > if result.has_key?("Value) > > > p result["Value"] && > result["#{Value}"]["query"]["location"]["data"] > > end > > Which will give me something like No, it most likely won't. Partly because there is a syntax error right in the first line of the code. You also mix "Value" and "#{Value}" which are two totally different things. > [{"Value-1"=>"Thu Dec 20 12:41:33 EST 2012"}, {"Value-7"=>"Wed Dec 19 > 11:37:00 EST 2012"}, {"Value-8"=>"Sun Jan 06 12:08:58 EST 2013"}] You would need to tell us what values you have there in the Hash - if it is a Hash at all. > now from this result i want to see > if result has values like : Value-8 , then it will say "found the > result" Did you mean "if result has _keys_ like 'Value-8'"? Because you use "Value" as key above. > but i cant get my head round about how to do this. > > mainly i think its a hash inside a array. and having issues > Can any one please help me Frankly, I am not entirely sure what you are after. If you want to select based on keys in the Hash you could do: result.select {|k,v| /\AValue-\d+\z/ =~ k} Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/