remove characters from string code example

Example 1: python remove string from string

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

Example 2: remove from string python

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

Example 3: java string remove character

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

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

Example 6: python remove specific character from string

s="Hello$ Python3$"s1=s.replace("$","",1)print (s1)#Output:Hello Python3$

Tags:

Php Example