Answers for "how to remove a letter from a string"

1

python remove letters from string

string = "abc123"
# Method 1
''.join(char for char in string if char.isdigit())

#Method 2
import re
re.sub("[^0-9]", "", string)
Posted by: Guest on December-03-2020
19

remove from string python

"Str*ing With Chars I! don't want".replace('!','').replace('*','')
Posted by: Guest on May-13-2020
1

remove letter from string python

a_string = a_string.replace("d", "")
Posted by: Guest on March-20-2021
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 charachter from string

StringBuilder sb = new StringBuilder(inputString);
Posted by: Guest on February-02-2021
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 a letter from a string"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language