---
title: "How to remove special characters from an string?"  
description: "How to remove special characters from an string?"  
author: "Anonymous User"  
published: 2013-10-04  
updated: 2013-10-04  
canonical: https://www.mindstick.com/forum/1580/how-to-remove-special-characters-from-an-string  
category: "java"  
tags: ["java"]  
reading_time: 1 minute  

---

# How to remove special characters from an string?

I want to [remove](https://yourviews.mindstick.com/story/4554/8-harmful-weeds-to-remove-from-garden) [special character](https://www.mindstick.com/forum/119/special-character-remove-from-url-or-any-string) like:

```
- + ^ . : ,
```

from a [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) using java.

## Replies

### Reply by Anonymous User

Try replaceAll() method of the String class.

BTW here is the method, return type and parameters.

```
public String replaceAll(String regex, String replacement)
```

## Example:

```
String str = "Hello +-^ my + - friends ^ ^^-- ^^^ +!";
```

```
str = str.replaceAll("[-+^]*", "");
```

It should remove all the {'^', '+', '-'} chars that you wanted to remove!

### Reply by Anonymous User

Post is removed by the Admin.


---

Original Source: https://www.mindstick.com/forum/1580/how-to-remove-special-characters-from-an-string

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
