title: remove all special characters in java
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1805518/replacing-all-non-alphanumeric-characters-with-empty-strings">Replacing all non-alphanumeric characters with empty strings</a>  </p>
  </blockquote>
  
  
  
  <pre><code>import java.util.Scanner;
  import java.util.regex.*;
  public class io{
  public static void main(String args[]){
  Scanner scan = new Scanner(System.in);
  String c;
  if((c=scan.nextLine())!=null)
   {
  Pattern pt = Pattern.compile("[^a-zA-Z0-9]");
  Matcher match= pt.matcher(c);
      while(match.find()){
           c=c.replace(Character.toString(c.charAt(match.start())),"");
           }
      System.out.println(c);
        }
     }
  }
  </code></pre>
  
  <p><strong>Case 1</strong></p>
  
  <pre><code>Input : hjdg$h&amp;jk8^i0ssh6
  Expect : hjdghjk8i0ssh6
  Output : hjdgh&amp;jk8^issh6
  </code></pre>
  
  <p><strong>Case 2</strong></p>
  
  <pre><code>Input : hjdgh&amp;jk8i0ssh6
  Expect : hjdghjk8i0ssh6
  Output : hjdghjk8i0ssh6
  </code></pre>
  
  <p><strong>Case 3</strong></p>
  
  <pre><code>Input : hjdgh&amp;j&amp;k8i0ssh6
  Expect : hjdghjk8i0ssh6
  Output : hjdghjki0ssh6
  </code></pre>
  
  <p>Anyone please help me to figure out, what is wrong in my code logic ?? </p>