From: 7stud -- Date: 2009-08-17T14:16:09+09:00 Subject: Re: Reading contents of a file and storing Shekar Ls wrote: > > Since i am new to programming lang, i dont know how to write a regex. > I am looking for output like this > > a = "http://localhost" > b = "User@htmdec.com" > > where a & b are variables i am storing these values into. You would never do that. You store multiple values in arrays. For instance, data = ["hello", "hi", "goodbye"] puts data[1] --output:-- "hi" You can get the data out of your file without using regex's like this: results = [] IO.foreach("data.txt") do |line| pieces = line.split("=") val = pieces[1].strip #remove spaces on the left and the right val = val[1...-1] #slice off the quotes results << val end p results --output:-- ["http://localhost", "User@htmdec.com", "12345678", "iexplore"] -- Posted via http://www.ruby-forum.com/.