Java String Camel Case to Snake Case camelToSnake(final String camelStr)

Here you can find the source of camelToSnake(final String camelStr)

Description

camel To Snake

License

Open Source License

Declaration

public static String camelToSnake(final String camelStr) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {

    public static String camelToSnake(final String camelStr) {
        String ret = camelStr.replaceAll("([A-Z]+)([A-Z][a-z])", "$1_$2").replaceAll("([a-z])([A-Z])", "$1_$2");
        return ret.toLowerCase();
    }//from w  ww .  j a v a 2  s.co  m
}

Related

  1. camelToSnake(String camel, boolean upper)
  2. camelToSnake(String value)
  3. camelToSnakeCase(final String camelCase)
  4. camelToSnakeCase(String camelcase)