Java String Uncapitalize uncapitalize(String str)

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

Description

uncapitalize

License

Apache License

Declaration

public static String uncapitalize(String str) 

Method Source Code

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

public class Main {
    public static String uncapitalize(String str) {
        if (str == null || str.isEmpty()) {
            return str;
        }//from   w w  w. j  a  v a2  s  .c om
        int capitalIndex = -1;
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) >= 'A' && str.charAt(i) <= 'Z') {
                capitalIndex = i;
            } else {
                break;
            }
        }
        if (capitalIndex < 0) {
            return str;
        } else if (capitalIndex == str.length() - 1) {
            return str.toLowerCase();
        } else {
            return str.substring(0, capitalIndex + 1).toLowerCase() + str.substring(capitalIndex + 1);
        }
    }
}

Related

  1. uncapitalize(String str)
  2. uncapitalize(String str)
  3. uncapitalize(String str)
  4. uncapitalize(String str)
  5. uncapitalize(String str)
  6. uncapitalize(String str)
  7. uncapitalize(String str)
  8. unCapitalize(String str)
  9. uncapitalize(String str)