From: Scott Sweeney Date: 2007-12-08T03:58:05+09:00 Subject: Re: how to use split method in ruby dare ruby wrote: > hi friends, > > i have created a onject for string class, like > > @news = String.new > > and added contents using > > @news >> somevalue > > "somevalue" includes some alphabets, numbers, even whitespaces, special > characters. > > now i need to seperate @news based on whitespace like > > if @news contains 'kick the ball" > i need out put as, like > > kick > the > ball > same if @ news contains 'kick the="size" ball="blue"" > > i need to split and output should be like > > kick > the > ball > Some message : size > blue > > how to solve this problem using ruby? > > Thanks in advance.... Well, I'm still very new to Ruby, but I came across something similar that I needed to do already. Maybe it can help you. If you do the following: news = 'kick the="size" ball="blue"' news_word_array = news.gsub(/[\"=]/ ' ').split It should return all of the words you are asking for in an array and then you can call and arrange that data in whatever way you see fit. Nigama -- Posted via http://www.ruby-forum.com/.