title: Remove certain characters from string
body: <p>I want to create a program that gives the number of characters, words, etc... in a user-inputted string. To get the word count I need to remove all the periods and commas form a string. So far I have this:</p>
  
  <pre><code>import javax.swing.JOptionPane;
  public class WordUtilities
  {
     public static void main(String args[])
     {
        {
        String s = JOptionPane.showInputDialog("Enter in any text.");
  
        int a = s.length();
        String str = s.replaceAll(",", "");
        String str1 = str.replaceAll(".", "");
        System.out.println("Number of characters: " + a);
        System.out.println(str1);
        }
     }
  }
  </code></pre>
  
  <p>But in the end I get only this:</p>
  
  <pre><code>Number of characters: (...)
  </code></pre>
  
  <p>Why is it not giving me the string without the commas and periods? What do I need to fix?</p>