I am thinking about using String.replaceAll() to remove certain characters in my string. It is unclear which characters are going to be removed (i.e. which char
I think this can be done by using regular expressions.
Firstly, we know [a-zA-Z]and $%! is valid for characters in string. So we use regx "[^a-zA-Z0-9$%!]" to strip out the other invalid chars.
check http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html for detail info of JAVA patten.
Next, we can usemystring.replaceAll(String regex, String replacement)
P.S. RefexPlanet online Regular Expression Test Page