how to check a string for a special character in Java
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/1795402/java-check-a-string-if-there-is-a-special-character-in-it">JAVA: check a string if there is a special character in it</a>  </p>
</blockquote>



<p>I'm testing a method that transforms a string into another string except it preservers all special characters (non alpha-numeric).  </p>

<p>So I'm looking to test the output of this method to ensure it actually preserves these characters.<br>
I know this calls for use of <code>Pattern</code> and <code>Matcher</code> classes but not sure how.<br>
I think I need to build a format template, compile it with <code>Pattern</code> and then use it with <code>Matcher</code> with the output string of my test method
.<br>
So I'll build the format template character by character. For digits and characters, I can use IsLetter and IsDigit of Character class and insert <code>"\\d"</code> for digit in my template.<br>
Not sure what I should use for letters and special characters.</p>

<p>Any Ideas?</p>

<p>Thanks.</p>
