From: Hassan Schroeder Date: 2009-12-27T02:20:10+09:00 Subject: Re: How to parse this file On Sat, Dec 26, 2009 at 9:03 AM, Rajinder Yadav wrote: > here is the basic code, output followed by a basic explanation >   data=line.match /\"(\w+)\"\s+\"(\w+)\"/ ?? That won't remotely work, unless the "Question" and "Answer" are both single words, which seems unlikely :-) Try something like line.chomp.match /\"([^"]+)\"\s+\"([^"]+)\"/ >> '"What is the temperature?" "Pretty cold"'.match /\"(\w+)\"\s+\"(\w+)\"/ => nil >> '"What is the temperature?" "Pretty cold"'.match /\"([^"]+)\"\s+\"([^"]+)\"/ => # >> result = '"What is the temperature?" "Pretty cold"'.match /\"([^"]+)\"\s+\"([^"]+)\"/ => # >> result[1] => "What is the temperature?" >> result[2] => "Pretty cold" >> -- Hassan Schroeder ------------------------ hassan.schroeder@gmail.com twitter: @hassan