String removeAlienCharacters(String str){ String newString = new String(); String returnString = ""; if(str.contains("<")){ String[] str2 = str.split("<"); str = str2[0]; } for(char x: str.toCharArray()){ if((x >= 48 && x <= 57) || (x>=65 && x <= 90) || (x >= 97 && x<= 122) || x=='.'){ returnString += x; } } return returnString.trim(); }
String str = new String("Hello World"); String newStr = CharSetUtils.delete(str, "abcde"); System.out.println(newStr); // prints Hllo Worl
String str = new String("What's Up ?"); String newStr = CharSetUtils.delete(str, "'?"); System.out.println(newStr); // prints Whats Up