Java String Decamel Case deCamelCase(final String original)

Here you can find the source of deCamelCase(final String original)

Description

Converts a camel cased string into an underscored one, e.g.

License

BSD License

Parameter

Parameter Description
original the camel cased string

Return

de-camel-cased string (or null if original is null)

Declaration

public static String deCamelCase(final String original) 

Method Source Code

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

public class Main {
    /**/*from  ww  w .  j a  v a 2  s .  co  m*/
     * Converts a camel cased string into an underscored one, e.g. {@code fooBar}
     * {@literal ->} {@code foo_bar}
     *
     * @param original
     *     the camel cased string
     * @return de-camel-cased string (or null if original is null)
     */
    public static String deCamelCase(final String original) {
        if (original == null)
            return null;
        if (original.isEmpty())
            return original;
        return original.replaceAll("(.)(\\p{Upper})", "$1_$2").toLowerCase();
    }
}

Related

  1. decamel(String name)
  2. deCamelCap(String s)
  3. deCamelCase(String camelCased, String delim)
  4. deCamelCase(String identifier)
  5. deCamelCaseStyle(String style)
  6. decamelise(String testName)