zoukankan      html  css  js  c++  java
  • java判断字符串String中是否存在中文

    public class IsContainChinese {

      public static boolean isContainChinese (String str){

        boolean flag=true;

        int count = 0;

        String regEx = "[\u4e00-\u9fa5]";

        Pattern p = Pattern.compile(regEx);

        Matcher m = p.matcher(str);

        while (m.find()) {

          for (int i = 0; i <= m.groupCount(); i++) {

            count++;

          }

        }

        if(count==0){

          flag=false;

        }

        return flag;

      }

      public static void main(String[] args) {

        System.out.println(isContainChinese("我是lzhl"));

      }

    }

  • 相关阅读:
    IDEA快捷方式
    JVM调优总结
    log4g详细配置
    大前端完整学习路线(详解)
    Tomcat工作原理
    Oracle
    Servlet知识
    lmap
    常见博客API
    PL/SQL入门理解(一)
  • 原文地址:https://www.cnblogs.com/lzhl/p/6379508.html
Copyright © 2011-2022 走看看