remove character from string 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: Java remove character from string

// remove last character from string in java
public class SubstringDemo
{
   public static void main(String[] args)
   {
      String strInput = "Flower Brackets!";
      String strOutput = strInput.substring(0, strInput.length() - 1);
      System.out.println(strOutput);
   }
}

Example 4: remove occurrence in string pytthon

str="it is icy"
print str.replace("i", "")

Example 5: remove from string python

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

Example 6: javascript remove character from string

mystring.replace(/r/g, '')

Tags:

Cpp Example