On 5/7/07, Nanyang Zhan <sxain / hotmail.com> wrote:> Don't get me wrong, because I just want to know how to separate English> words from a string with ruby.> There are strings (UTF-8 encoded) to record people's name,> like:>> 摩根·弗里曼 Morgan Freeman> 布鲁斯·威利斯 Bruce Willis> 李小明 Lee xiao ming> these strings containing Chinese name(without space between characters),> separated by a space, following an English name>> or> Frank Darabont> Just an English name.>> Would you give me an idea how to separate these Chinese characters(if> any)?>> --> Posted via http://www.ruby-forum.com/.>>
Try something like this.
t = str.split(//).partition {|x| x=~/[a-z]|[A-Z]/ }p t[0].joinp t[1].join
Harry
-- http://www.kakueki.com/ruby/list.htmlA Look into Japanese Ruby List in English