Java Utililty Methods String Decamel Case

List of utility methods to do String Decamel Case

Description

The list of methods to do String Decamel Case are organized into topic(s).

Method

Stringdecamel(String name)
decamel
if (name == null)
    return null;
return name.replaceAll(String.format("%s|%s|%s", "(?<=[A-Z])(?=[A-Z][a-z])", "(?<=[^A-Z])(?=[A-Z])",
        "(?<=[A-Za-z])(?=[^A-Za-z])"), " ");
StringdeCamelCap(String s)
de Camel Cap
if (s.length() == 0)
    return s;
return Character.toUpperCase(s.charAt(0)) + deCamel(s.substring(1));
StringdeCamelCase(final String original)
Converts a camel cased string into an underscored one, e.g.
if (original == null)
    return null;
if (original.isEmpty())
    return original;
return original.replaceAll("(.)(\\p{Upper})", "$1_$2").toLowerCase();
StringdeCamelCase(String camelCased, String delim)
de Camel Case
final StringBuilder path = new StringBuilder();
boolean lastUpper = true;
for (char c : camelCased.toCharArray()) {
    if (Character.isUpperCase(c)) {
        c = Character.toLowerCase(c);
        if (!lastUpper) {
            lastUpper = true;
            path.append(delim);
...
StringdeCamelCase(String identifier)
de Camel Case
if (identifier == null || identifier.isEmpty()) {
    return null;
StringBuilder nameBuilder = new StringBuilder();
for (int i = 0; i < identifier.length(); i++) {
    char c = identifier.charAt(i);
    if (i == 0) {
        nameBuilder.append(Character.toUpperCase(c));
...
StringdeCamelCaseStyle(String style)
convert for example backgrounColor to background-color
String property = "";
for (int j = 0; j < style.length(); j++) {
    char character = style.charAt(j);
    if (Character.isUpperCase(character)) {
        property += "-" + Character.toLowerCase(character);
    } else {
        property += character;
return property;
Stringdecamelise(String testName)
decamelise
String nocamel = charAtToUpper(0, testName);
for (int i = 1; i < testName.length(); i++) {
    char nextChar = testName.charAt(i);
    if (isUpper(nextChar)) {
        nocamel += spaceAndToLower(nextChar);
    } else {
        nocamel += nextChar;
return nocamel;
Stringdecamelize(final String s)
decamelize
if (s == null) {
    return null;
if (s.length() == 1) {
    return s.toUpperCase();
StringBuilder buf = new StringBuilder(40);
int pos = 0;
...
Stringdecamelize(String s)
decamelize
if (s == null || s.equals("")) {
    return s;
StringBuffer buf = new StringBuffer();
buf.append(Character.toLowerCase(s.charAt(0)));
for (int i = 1; i < s.length(); i++) {
    if (Character.isUpperCase(s.charAt(i))) {
        if (s.length() > i + 1 && Character.isLowerCase(s.charAt(i + 1))) {
...
StringdeCamelize(String value)
de Camelize
if (value == null) {
    return null;
StringBuilder deCamelized = new StringBuilder(value.length() + 10);
for (int i = 0; i < value.length(); i++) {
    if (Character.isUpperCase(value.charAt(i)) && deCamelized.length() > 0) {
        deCamelized.append('_');
    deCamelized.append(Character.toUpperCase(value.charAt(i)));
return deCamelized.toString();