Removing certain characters from a string
<p>I am thinking about using <code>String.replaceAll()</code> to remove certain characters in my string. It is unclear which characters are going to be removed (i.e. which characters I want to remove), but I would assume that any character is valid (like <code>[a-zA-Z]</code> and things like <code>$%!</code>, etc).</p>

<p>I came across <a href="http://www.java-tips.org/java-se-tips/java.lang/strip-certain-characters-from-a-string.html" rel="nofollow">http://www.java-tips.org/java-se-tips/java.lang/strip-certain-characters-from-a-string.html</a> but surely there is a better way than iterating over each character...</p>

<p>Any thoughts on this?</p>

<p>Thanks</p>

<p>EXAMPLE:</p>

<p>Just to clarify, I will have strings of varying lengths. I want to strip characters from it, the exact ones to be determined at runtime, and return the resulting string.</p>

<p>Taking the paragraph above and allowing me to strip out the "<code>,.</code>", I would return the string:</p>

<blockquote>
  <p>Just to clarify I will have strings of
  varying lengths I want to strip
  characters from it the exact ones to
  be determined at runtime and return
  the resulting string</p>
</blockquote>

<p>As an aside, I know that replaceAll() uses regular expressions, so if I wanted to strip out the characters "$,.", I would need to escape them too, right?</p>
