Title: Remove specific char from String
Tags: java;android;string;removeall
Question: How To remove a specific Character from a String. I have a Arraylist testingarray.

```String line=testingarray.get(index).toString();
```

I want to remove a specific character from line.

I have Array of uniCodes

```int uniCode[]={1611,1614,1615,1616,1617,1618};
```

i want to remove those characters that have these Unicodes.

Comment: Can you give an example what you mean by _remove a specific character_

Comment: Do you want to remove all `d` characters?

Comment: possible duplicate of [how to remove special characters from an string?](http://stackoverflow.com/questions/7552253/how-to-remove-special-characters-from-an-string)

Comment: For Example I want to remove 'd' from a string( this is a dog ). Result should be( this is a og ).

Comment: @Amulya Khare yes i want to remove all d characters

Here is the accepted answer: use :

```NewString = OldString.replaceAll("char", "");
```

in your Example in comment use:

```NewString = OldString.replaceAll("d", "");
```

for removing Arabic character please see following link

how could i remove arabic punctuation form a String in java

removing characters of a specific unicode range from a string

Comment for this answer: thanks . i did it but i did't get what i want. Basically i want i have 7 unicodes of Arabic characters , int uniCode[]={1611,1614,1615,1616,1617,1618}; i want to remove those words that have these unicodes
Comment for this answer: @ Shayan pourvatan thanks a lot . That is what i was searching i got my solution.

Here is another answer: Try this,

```String result = yourString.replaceAll("your_character","");
```

Example:

```String line=testingarray.get(index).toString();
String result = line.replaceAll("[-+.^:,]","");
```

Comment for this answer: replaceAll("[-+.^:,]","")    - this is working as a regEx and if anything is present in line , it is replacing with blank( trimming it).

Here is another answer: you can replace character using replace method in string.

```String line = "foo";
line = line.replace("f", "");
System.out.println(line);
```

output

```oo
```

Comment for this answer: Cleanest solution for my application.

Here is another answer: If it's a single char, there is no need to use replaceAll, which uses a regular expression. Assuming "H is the character you want to replace":

```String line=testingarray.get(index).toString();
String cleanLine = line.replace("H", "");
```

update (after edit):
since you already have an int array of unicodes you want to remove (i'm assuming the Integers are decimal value of the unicodes):

```String line=testingarray.get(index).toString();
int uniCodes[] = {1611,1614,1615,1616,1617,1618};
StringBuilder regexPattern = new StringBuilder("[");
for (int uniCode : uniCodes) {
    regexPattern.append((char) uniCode);
}
regexPattern.append("]");
String result = line.replaceAll(regexPattern.toString(), "");
```


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 4, 'CommentCount': 5, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2013:00:12/25/13', 'FavoriteCount': 5.0, 'PostTypeId': 1, 'Tags': '<java><android><string><removeall>', 'Title': 'Remove specific char from String', 'ViewCount': 94939, 'id': 20769908, 'user_AboutMe': '', 'user_AccountId': 3395798.0, 'user_DisplayName': 'M.ArslanKhan', 'user_Reputation': 3236.0, 'user_Views': 496.0, 'user_id': 2849458.0}}