Java String Camel Case to Underscore camelCaseToUnderscore(String camelCased)

Here you can find the source of camelCaseToUnderscore(String camelCased)

Description

camel Case To Underscore

License

Apache License

Declaration

static String camelCaseToUnderscore(String camelCased) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    static String camelCaseToUnderscore(String camelCased) {
        // guava has best solution for this with CaseFormat class
        // but don't want to add dependency just for this method
        final String regex = "([a-z])([A-Z]+)";
        final String replacement = "$1_$2";
        return camelCased.replaceAll(regex, replacement);
    }//from   w ww .  jav a  2s  .  co m
}

Related

  1. camelCaseToLowerCaseUnderline(String name)
  2. camelCaseToUnderline(String name)
  3. camelCaseToUnderscore(final String camelCaseString)
  4. camelCaseToUnderscore(final String str)
  5. camelCaseToUnderscore(String camelCase)
  6. camelCaseToUnderScore(String key)
  7. camelCaseToUnderscored(String camelCaseName)
  8. camelCaseToUnderscores(String camel)
  9. camelCaseToUnderScoreUpperCase(String camelCase)