Java String Decamel Case decamelizeAndReplaceByHyphen(String s)

Here you can find the source of decamelizeAndReplaceByHyphen(String s)

Description

Replaces the Capital letters with lower letters and prefixed with a hyphen if not in the beginning of the string.

License

Open Source License

Parameter

Parameter Description
s raw string

Return

the string processed

Declaration


static public String decamelizeAndReplaceByHyphen(String s) 

Method Source Code

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

public class Main {
    /** /*from   ww w  .  j  av  a 2s . c  om*/
     * Replaces the Capital letters with lower letters and prefixed with a hyphen if not in the beginning of the string.
     * For instance PTM info becomes ptm-info and modifiedResidue becomes modified-residue 
     * @param s raw string
     * @return the string processed 
     */

    static public String decamelizeAndReplaceByHyphen(String s) {
        return s.trim().replaceAll("(\\p{Ll})(\\p{Lu})", "$1 $2").replaceAll(" ", "-").toLowerCase();
    }
}

Related

  1. deCamelCaseStyle(String style)
  2. decamelise(String testName)
  3. decamelize(final String s)
  4. decamelize(String s)
  5. deCamelize(String value)