java remove all letters from string code example
Example 1: java remove non numbers from string
String str = "a12.334tyz.78x";
str = str.replaceAll("[^\\d.]", "");
Example 2: how to remove letters from string java
public extractLetters(String str){
String result="";
for(int i= 0; i< str.length; i++){
if(Character.isLetter(str.charAt(i))){
result+=str.charAt(i);
}
}
Example 3: how to remove all characters before a certain character from a string in java
String s = "the text=text";
String s1 = s.substring(s.indexOf("=")+1);
s1.trim();