• java正则,将<a或者</a,尖括号后面的字母改成大写


    java正则,将<a或者</a,尖括号后面的字母改成大写

    /**
         * 将<a或者</a中的a,转为大写字母
         * @param xmlStr
         * @return
         */
        public static String firstLabelToUppper(String xmlStr){
            Pattern p = Pattern.compile("\<[a-z|A-Z]");
            Matcher m = p.matcher(xmlStr);
            StringBuffer sb = new StringBuffer();
            while (m.find())
            { // Find each match in turn; String can't do this.
    //String name = m.group(1); // Access a submatch group; String can't do this.
                m.appendReplacement(sb,  m.group().toUpperCase());
               // System.out.println("m.group() is= " + m.group());
            }
            m.appendTail(sb);
            //System.out.println("sb is= " + sb);
    
            return lastLabelToUppper(sb.toString());
        }
    
        /**
         * 将<a或者</a中的a,转为大写字母
         * @param xmlStr
         * @return
         */
        public static String lastLabelToUppper(String xmlStr){
            Pattern p = Pattern.compile("\</[a-z|A-Z]");
            Matcher m = p.matcher(xmlStr);
            StringBuffer sb = new StringBuffer();
            while (m.find())
            { // Find each match in turn; String can't do this.
    //String name = m.group(1); // Access a submatch group; String can't do this.
                m.appendReplacement(sb,  m.group().toUpperCase());
                //System.out.println("m.group() is= " + m.group());
            }
            m.appendTail(sb);
            //System.out.println("sb is= " + sb);
    
            return sb.toString();
        }
    

      

  • 相关阅读:
    werfault进程使用CPU率高
    oracel 拆分字符串
    TCP TIME WAIT
    netstat 命令
    Java 理论与实践: 并发集合类
    DIV与SPAN之间有什么区别
    oracle超出打开游标的最大数的原因和解决方案
    Quartz表达式
    Axis创建webservice客户端和服务端
    Web服务cxf框架发布2
  • 原文地址:https://www.cnblogs.com/achengmu/p/13546808.html
Copyright © 2020-2023  润新知