On 4-Nov-06, at 10:51 AM, Kevin Stolt wrote: > Hi, > > I am new to ruby and I have been search and pulling my hair to do this > using .scan? > > I have file which contains.....(this is an example) > > bat rat cat mat pat > mat sat put tomorrow today > > > So how could I search so I could get the values in the second column? > > I want to find "rat" and "sat" for example. I searched many time and > read many things but I can't figure out. I hope someone would be kind > enough to help me or show me the correct direction. > > any help is appreciated. You might want to look at String#split, e.g. >> "bat rat cat mat pat".split(' ', 3) => ["bat", "rat", "cat mat pat"] and pull out the second element, or you could use a regular expression >> "bat rat cat mat pat".match(/\s(\S+)\s/)[1] => "rat" These are just suggestions, and if you care about efficiency and robustness then you should understand them and see if they offer any good starting points. Hope this helps, Mike -- Mike Stok <mike / stok.ca> http://www.stok.ca/~mike/ The "`Stok' disclaimers" apply.