How to remove all the punctuation except whitespaces or numbers in java
<p>How to remove all the punctuation <em>except</em> whitespaces or numbers in Java.</p>

<pre><code>"\\p{Punct}|\\d", "" //THIS WORKS BUT IT REMOVES THE NUMBERS AND I DONT WANT IT TO REMOVE THE NUMBERS...
</code></pre>

<p>I am reading text and I need to remove punctuation.</p>

<pre><code>String[] internal;
char ch = 'a';
int counter = 1;
int count;
int c;
Map&lt;String, Set&gt; dictionary = new HashMap&lt;String, Set&gt;();
BufferedReader in = new BufferedReader(new FileReader("yu.txt"));
while (in.ready()) {
    internal = (((in.readLine()).replaceAll("\\p{Punct}|\\d", "")).toLowerCase()).split(" ");//this does not work in my case cause it removes numbers... and makes them whitespaces but other than that this one works I JUST dont want it to remove numbers and keep whitespaces...
    for (count = 0; count &lt; internal.length; count++) {
        if (!dictionary.containsKey(internal[count])) {
            dictionary.put(internal[count], new HashSet());
        }
        if (dictionary.get(internal[count]).size()&lt;10)
        {
        dictionary.get(internal[count]).add(counter);
        }
    }
    counter++;
}
Iterator iterator = dictionary.keySet().iterator();  
while (iterator.hasNext()) {  
String key = iterator.next().toString();  
String value = dictionary.get(key).toString();  
System.out.println(key + ": " + value );  
}  
</code></pre>
