判断输入的字符串是否为中文

public class JudgeChinese {
    public static void main(String[] args) {
        String s = "中文1";
        String regex = "[\u4E00-\u9FA5]+";
        if (s.matches(regex)) {
            System.out.println("输入是中文");
        }else{
            System.out.println("输入的不是中文");
        }
    }
}

 

posted @ 2018-08-28 10:09  宇枫  阅读(933)  评论(0编辑  收藏  举报