zoukankan      html  css  js  c++  java
  • 下滑线转换为驼峰

    下划线转驼峰

     1 public static Object underline2Camel(String line,boolean smallCamel){
     2         if(line==null||"".equals(line)){
     3             return "";
     4         }
     5         StringBuffer sb=new StringBuffer();
     6         Pattern pattern=Pattern.compile("([A-Za-z\d]+)(_)?");
     7         Matcher matcher=pattern.matcher(line);
     8         while(matcher.find()){
     9             String word=matcher.group();
    10             sb.append(smallCamel&&matcher.start()==0?Character.toLowerCase(word.charAt(0)):Character.toUpperCase(word.charAt(0)));
    11             int index=word.lastIndexOf('_');
    12             if(index>0){
    13                 sb.append(word.substring(1, index).toLowerCase());
    14             }else{
    15                 sb.append(word.substring(1).toLowerCase());
    16             }
    17         }
    18         return sb.toString();
    19     }
  • 相关阅读:
    BZOJ 3522 Hotel
    BZOJ 1864 三色二叉树
    396595
    CodeForces
    CodeForces
    CodeForces
    E. 数字串
    算术基本定理总结
    Cyclic Nacklace 杭电3746
    Period
  • 原文地址:https://www.cnblogs.com/LifeFruit/p/13839088.html
Copyright © 2011-2022 走看看