2017  Kodetalk | Feedback | Privacy Policy | Terms | About

How to replace all special character of a string using java

For example i have a string:

String s = "Now& uyu876876 %$#^%*&^*&^*&";

I want to remove all character of a string using java. How to do?


If you want replace all special character use below code:


or else if u want to replace only specific chars use below code

s.replaceAll("[()?:!.,;]+", ""); // you can add/remove based on your requirement
Answer is