Answered by : rohit-ghodadra
<?php
// IF ONLY CHARACTER IN STRINGS
$str = "Hello PHP";
echo str_replace("PHP","",$str); // its remove PHP From string
//Output = Hello;
// IF NUMARIC OR CHARACTERS IN STRING AND YOU NEED ONLY STRING
$strInt = "124Peter56";
echo $words = preg_replace('/[0-9]+/', '', $strInt); // it remove integer from string
// Output = Peter;
// IF NUMARIC OR CHARACTERS IN STRING AND YOU NEED ONLY INTEGERS
$strInt = "124Peter56";
echo $res = preg_replace("/[^0-9]/", "", $strInt ); // It Remove all string
// Output = 12456
?>
Source : | Last Update : Sat, 02 Apr 22
Answered by : mysterious-mole-y1g4oq76tyse
s = 'ab12abc34ba'
print(s.replace('ab', ''))
Source : https://www.journaldev.com/23674/python-remove-character-from-string | Last Update : Sat, 19 Sep 20
Answered by : sander-bergman
s = 'abc12321cba'
print(s.replace('a', ''))
#result
'bc12321cb'
Source : https://www.journaldev.com/23674/python-remove-character-from-string | Last Update : Fri, 01 Jul 22
Answered by : exuberant-eel-2vjub8sho7i7
"Str*ing With Chars I! don't want".replace('!','').replace('*','')
Source : | Last Update : Wed, 20 May 20
Answered by : momin-iqbal
original_string = "This is a 'string' with single quotes."
modified_string = original_string.replace("'", "")
print(modified_string)
Source : | Last Update : Thu, 18 May 23
Answered by : vtek-mikulek
string TrimWordsFromString(string value, int numberOfWords, char separator, bool reverse)
{ int trimmedWords = 0; int index = 0; while(trimmedWords != numberOfWords) { if(value == string.Empty) { return string.Empty; } if(reverse) { index = value.Length - 1; } if(value[index] == separator) { trimmedWords++; } value = value.Remove(index, 1); } return value;
}
Source : | Last Update : Wed, 31 Aug 22
Answered by : obedient-ocelot-5tkogtygmlyl
public extractLetters(String str){ String result=""; for(int i= 0; i< str.length; i++){ if(Character.isLetter(str.charAt(i))){ result+=str.charAt(i); } }
Source : | Last Update : Thu, 21 Jan 21
Answered by : y-hari-priya
public class RemoveCharacter
{ public static void main(String[] args) { String MyString = "Hello World"; System.out.println("The string before removing character: " + MyString); MyString = MyString.replace("e", ""); System.out.println("The string after removing character: " + MyString); }
}
Source : https://www.delftstack.com/howto/java/java-remove-character-from-string/ | Last Update : Wed, 06 Jul 22
Answered by : inexpensive-impala-uf0v3jcl13n9
StringBuilder sb = new StringBuilder(inputString);
Source : https://stackoverflow.com/questions/13386107/how-to-remove-single-character-from-a-string | Last Update : Tue, 09 Feb 21