Java String to convertStringToVarName(final String str)

Here you can find the source of convertStringToVarName(final String str)

Description

convert String To Var Name

License

Creative Commons License

Declaration

public static String convertStringToVarName(final String str) 

Method Source Code

//package com.java2s;
/*/*from  w  ww  . ja  v a  2  s.  c om*/
 * Copyright (c) 2013 - 2015 Naios <naios-dev@live.de>
 *
 * This file is part of WIde which is released under Creative Commons 4.0 (by-nc-sa)
 * See file LICENSE for full license details.
 */

public class Main {
    public static String convertStringToVarName(final String str) {
        return str.toUpperCase().replaceAll("[:punct:\\(\\)\\]\\['-]", "").replaceAll(" +", "_");
    }
}

Related

  1. convertStringToPrimaryKey(String keyString)
  2. convertStringToPrimitive(Object object, Class toType)
  3. convertStringToPrimitive(String value, Class destinationClass)
  4. convertStringToSafeFilename(String s)
  5. convertStringToValue(String txt, Class klass)
  6. convertStringToWord(String strValue)
  7. convertStringWithReplacementPattern(final String originalString, final String pattern, final String replace)