remove string from string in java code example
Example 1: Java remove character from string
public class RemoveOnlyLetters
{
public static void main(String[] args)
{
String strExample = "jd15352kLJJD55185716kdkLJJJ";
System.out.println("Before: " + strExample);
strExample = strExample.replaceAll("[a-zA-Z]", "");
System.out.println("After: " + strExample);
}
}
Example 2: java remove string from character
String str = "abcdDCBA123";
String strNew = str.replace("a", "");
Example 3: remove part of string java
String text = "Image.png";
String[] cutText = text.split("\\.");