From: Martin Jose Date: 2013-07-05T17:10:56+09:00 Subject: Re: Split string so your query is like, query = "Get /index.html HTTP/1.0\r\n\r\nHost: www.example.com\r\nConnection: Close\r\n\r\n" Now you do a simple regular expression to split the string like, split_string = query.split(/\r\n/) This will give you an array like this, split_string = ["Get /index.html HTTP/1.0", "", "Host: www.example.com", "Connection: Close" If you want to delete the null value from the above array just do, split_string.delete("") -- Posted via http://www.ruby-forum.com/.