string remove character code example

Example 1: python remove string from string

s = 'ab12abc34ba'
print(s.replace('ab', ''))

Example 2: delete certain characters from a string python

for char in line:
    if char in " ?.!/;:":
        line.replace(char,'')

Example 3: remove from string python

"Str*ing With Chars I! don't want".replace('!','').replace('*','')

Example 4: java string remove character

String str = "abcdDCBA123";
String strNew = str.replace("a", ""); // strNew is 'bcdDCBA123'

Example 5: how to delete character in string java

# subString(int start, int end);

String a = "Hello!";
b = a.subString(0,a.length()-1) #Remove the last String
# b should be "Hello" then

Example 6: 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);
	  	}
	}

Tags:

Java Example