Java String Underscore underscore(String str)

Here you can find the source of underscore(String str)

Description

underscore

License

Open Source License

Declaration

public static String underscore(String str) 

Method Source Code

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

public class Main {
    public static String underscore(String str) {
        if (str == null)
            return null;

        return str.replaceAll("([A-Z]+)([A-Z][a-z])", "$1_$2").replaceAll("([a-z])([A-Z])", "$1_$2")
                .replaceAll("-", "_").toLowerCase();
    }/*from   ww  w .  ja  va2s.c o  m*/
}

Related

  1. underscore(final String s, final Locale locale)
  2. underscore(String camel)
  3. underscore(String camelCaseWord)
  4. underscore(String field)
  5. underscore(String phase)
  6. underscore(String word)
  7. underscoreAllWhitespace(String str)
  8. underscoreAndLowercase(String s)
  9. underScoreBreakToCaseBreak (final String s)