underline Between Up Case - Java java.lang

Java examples for java.lang:String Case

Description

underline Between Up Case

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) {
        String str = "AbcDefDeDDDD";
        System.out.println(underlineBetweenUpCase(str));
    }/*from www .  j av a 2 s. c o  m*/

    public static String underlineBetweenUpCase(String str) {
        return str.replaceAll("(.)(\\p{Lu})", "$1_$2").toLowerCase();
    }
}

Related Tutorials