--1926193751-447327374-1247158239654 Content-Type: MULTIPART/MIXED; BOUNDARY="1926193751-447327374-1247158239=:7654" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --1926193751-447327374-1247158239654 Content-Type: TEXT/PLAIN; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8BIT Hi -- On Fri, 10 Jul 2009, Robert Klemme wrote: > 2009/7/9 David A. Black <dblack / rubypal.com>: >> Hi -- >> >> On Thu, 9 Jul 2009, Sarawut Poaitwinyu wrote: >> >>> I have working on tag system and There is information like this >>> >>> "important urgent project 2009" >>> >>> i want to seperate into word, one word at the time is okay >>> >>> What is the easiest way to separate those string word by word, space >>> between each word might has more than 1. >>> >>> My idea is to use loop to check character by character that it is space >>> or not, and then cut the part, but i thought it might have easier way >>> that i don't know >> >> ¨Âïòäó ôòéîç®óðìé>> >> When you call split with no argument, it splits on whitespace >> (including more than one character). > > I am more like the "positive" guy - meaning explicitly defining what I > want returned. I would do > > words tring.scan /\w+/ > > That way dot, question mark and other signs won't hurt. It may not > make a difference but it's probably good to see different approaches. string.split does explicitly define what I want back; it's just something different from what you want back :-) It depends exactly how you define "word". I was assuming it was /\S+/ but it may indeed be /\w+/ (or maybe /[^\W\d_]+/ or something). David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Now available: The Well-Grounded Rubyist (http://manning.com/black2) Training! Intro to Ruby, with Black & Kastner, September 14-17 (More info: http://rubyurl.com/vmzN) --1926193751-447327374-1247158239654-- --1926193751-447327374-1247158239654--