zoukankan      html  css  js  c++  java
  • 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();
        }
    

      

  • 相关阅读:
    通过Get-Group导出组的成员
    VNC Server (CentOS 7 GNOME)
    VNC Server (Ubuntu 16.04.3 GNOME)
    输入输出重定向
    Linux下的网卡Bonding
    硬件性能测试
    Linux里的稀疏文件
    Linux下CPU信息的查看
    工作中常用到的Linux命令
    Putty+Xming实现在Windows客户端显示Linux服务器端的图形化程序
  • 原文地址:https://www.cnblogs.com/achengmu/p/13546808.html
Copyright © 2011-2022 走看看