Java Java String Format toJavaIdentifier(String source)

Here you can find the source of toJavaIdentifier(String source)

Description

to Java Identifier

License

Open Source License

Declaration

public static String toJavaIdentifier(String source) 

Method Source Code

//package com.java2s;
/** ****************************************************************************
 * Copyright (c)  The Spray Project.//from w  ww  . j ava  2  s . c  o  m
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     Spray Dev Team - initial API and implementation
 **************************************************************************** */

public class Main {
    public static String toJavaIdentifier(String source) {
        String result = source.replaceAll(" ", "_");
        result = result.replaceAll("[)(*&^%$#@!\"':;<>?,./-]", "_");
        return result;
    }
}

Related

  1. toJavaHexCharString(final char chr)
  2. toJavaIdentifier(String name)
  3. toJavaIdentifier(String name)
  4. toJavaIdentifier(String nodeName, boolean boundary)
  5. toJavaIdentifier(String s)
  6. toJavaIdentifier(String str)
  7. toJavaIdentifier(String str)
  8. toJavaIdentifier(String str, String repl)
  9. toJavaIdentifier(String text, Boolean uppercaseFirst)