Java examples for java.lang:String Parse
This methods removes from string: \n \t ; |
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { String sentence = "java2s.com"; System.out.println(removeInvalidCharacters(sentence)); }/*from w w w . j a va 2 s.c o m*/ /** * This methods removes from string: \n \t ; | * @param sentence * @return string without invalid characters */ public static String removeInvalidCharacters(String sentence) { String result = sentence.replaceAll("\\n|\\t|\"|;|\\|", ""); return result.replaceAll(" ", " "); } }