检查字符串是否包含CJK(中文)字符 [英] Check if string contains CJK (chinese) characters

查看:162
本文介绍了检查字符串是否包含CJK(中文)字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要检查一个字符串是否包含中文字符。
搜索后我发现我必须看这个模式的正则表达式 \ u31C0-\\ _u31EF
但我不管理获得正则表达式的工作。

I need to check if a string contains chinese characters. After searching i found that i have to look with the regex on this pattern \u31C0-\u31EF, But i don't manage to get the regex work.

任何有这种情况的人?正则表达式是正确的吗?

Anyone experienced with this situation ? is the regex correct ?

推荐答案

正如所讨论的那样这里,在Java 7中(即正则表达式编译器符合要求来自UTS的RL1.2属性#18 Unicode正则表达式 ),您可以使用以下正则表达式匹配中文(好吧,CJK)字符:

As discussed here, in Java 7 (i.e. regex compiler meets requirement RL1.2 Properties from UTS#18 Unicode Regular Expressions), you can use the following regex to match a Chinese (well, CJK) character:

\p{script=Han}

可以是appreviated简单地

which can be appreviated to simply

\p{Han}

这篇关于检查字符串是否包含CJK(中文)字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆