title: Meaning behind underscore character in regular expressions
body: <p><strong>Note:</strong> My program works, I am just looking for an explanation as to why.</p>
  
  <p>I have a java program that reads a file, counts the words in said file, and outputs the words and counts to another file. In the first part of my I use a regular expression to replace any character not a letter and replace it with an empty string.</p>
  
  <pre><code>freq.add(in.next().replaceAll("[^A-Za-z]", ""));
  </code></pre>
  
  <p>This however does not account for hyphenated words so I changed the regEx to:</p>
  
  <pre><code>freq.add(in.next().replaceAll("[^A-Za-z_-]", ""));
  </code></pre>
  
  <p>My question is, why does adding the underscore and hyphen work? What is the meaning behind the underscore character?</p>
  
  <p>While I'm asking questions, are regex the same for all languages?</p>
  
  <p>Also, if this is answered somewhere else I apologize, I did numerous searches with no luck.</p>