
Removing characters from a string

Example:
public class CharReplace{
public static void main(String []args){
String str="Hello 123.you are At 3456";
String result=str.replaceAll("[a-z,A-Z]","");
System.out.println(result.trim());
}
}
Description: str.replaceAll(?type1?,?type2?) method replaces all type1 into type2.Here our goal to remove all char. so you can replace all character into ?? by using replaceAll() method. trim() method removes all blank spaces in the string.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
