I need some help regarding how to split Chinese characters mixed with English words and numbers in PHP.
For example, if I read
FrontPage 2000中文版應用大全
I’m hoping to get
FrontPage, 2000, 中,文,版,應,用,大,全
or
FrontPage, 2,0,0,0, 中,文,版,應,用,大,全
How can I achieve this?
Thanks in advance 🙂
Assuming you are using UTF-8 (or you can convert it to UTF-8 using Iconv or some other tools), then using the
umodifier (doc: http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php )will give
Note that my source code is stored in a file encoded in UTF-8 also, for the $s to contain those characters.
The following will match alphanumeric as a group:
result: