zoukankan      html  css  js  c++  java
  • 正则 函数

    public static String isContainType(String type, String str) {
            Pattern p = Pattern.compile(type);
            Matcher m = p.matcher(str);
            if (m.find()) {
                return m.group();
            }
            return null;
    }
     
    String containType = isContainType("[\u4e00-\u9fa5]+", "印花税-20181010-201810105.10城市维护建设税20180701-2018093013.82"); 
    System.out.println(
    "-38-->" + containType);//res: "印花税"; // 从头找到第一组汉字
    String containType = isContainType("[\u4e00-\u9fa5]+", "-20181010-201810105.10城市维护建设税20180701-2018093013.82"); 
    System.out.println("-39-->" + containType);//res: "
    城市维护建设税"; // 从头找到第一组汉字
     
  • 相关阅读:
    边框
    文本样式
    框架
    表格
    列表
    标签
    常用类--包装类
    常见类 --Object
    日志
    异常
  • 原文地址:https://www.cnblogs.com/hahajava/p/10183712.html
Copyright © 2011-2022 走看看