Java String Camel Case to Snake Case camelToSnakeCase(final String camelCase)

Here you can find the source of camelToSnakeCase(final String camelCase)

Description

converts ruby to camel case

License

Apache License

Declaration

public static String camelToSnakeCase(final String camelCase) 

Method Source Code

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

public class Main {
    /**/* w ww . j  a va 2  s . c  om*/
     * converts ruby to camel case
     */
    public static String camelToSnakeCase(final String camelCase) {
        // check for null
        if (camelCase == null || camelCase.isEmpty()) {
            return "";
        }

        // simple regex
        return camelCase.replaceAll("\\B([A-Z])", "_$1").toLowerCase();
    }
}

Related

  1. camelToSnake(final String camelStr)
  2. camelToSnake(String camel, boolean upper)
  3. camelToSnake(String value)
  4. camelToSnakeCase(String camelcase)
  5. camelToSnakeCase(String string)
  6. camelToSneakCase(String name)
  7. camelToUpperSnake(String camel)