Mariusz Pekala
5/7/2007 10:04:00 AM
On 2007-05-07 16:39:12 +0900 (Mon, May), Nanyang Zhan 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)?
Maybe a regexp similiar to
/^([^qazwsxedcrfvtgbyhnujmikolpQAZWSXEDCRFVTGBYHNUJMIKOLP ]+)/
would help?
Does [a-zA-Z] include Chinese characters? In Polish locale it includes
Polish non-ASCII characters, so I guess it might include Chinese ones.
I guess you want split a given string into words (separated by space),
and then check whether the first word starts or includes at least one
Chinese character.
--
No virus found in this outgoing message.
Checked by 'grep -i virus $MESSAGE'
Trust me.