Answers for "how to remove string"

1

how to remove letters from string

public extractLetters(String str){
	String result="";
	for(int i= 0; i< str.length; i++){
	    if(Character.isLetter(str.charAt(i))){
	    result+=str.charAt(i);
	  	}
	}
Posted by: Guest on January-14-2021
0

remove part of string java

// Works only if you have a certain character at which you want to cut
String text = "Image.png";

String[] cutText = text.split("\\.");

// cutText[0] has value "Image"
// cutText[1] has value "png"
Posted by: Guest on March-11-2020
0

take a string and a character, remove that character from string

cpp code
int main()
{
    string str;
    getline(cin,str);
    char c;
    cin>>c;
    
    string temp="";
    
    for(int i=0; i<str.size(); i++){
        
        if(str[i] == c)
          continue;
        temp += str[i];  
        
    }
    
    cout<<temp;

    return 0;
}
Posted by: Guest on August-11-2021

Code answers related to "how to remove string"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language