title: Matching different patterns to a string
body: <p>(This is sort of a follow up question to <a href="https://stackoverflow.com/questions/8437180/matching-multiple-strings-to-one-long-string-using-patterns">one I asked before</a>)</p>
  
  <p>So I have a DNA string </p>
  
  <p>e.g.</p>
  
  <pre><code>acagatgaaggaggacgcgcccccgccgctgtcctgcgcctcagccatcctatgagacgg
  </code></pre>
  
  <p>and I have 20 different 3 letter patterns (each combination corresponds to an amino acid) I want to match to the data.  My java program looks at 3 letters at a time and tries to match it to one of the patterns.  I want to eventually count the number of times each amino acid appears, so when I find a match I need to increment a particular counter.  I want to implement this using java regex, so I have:</p>
  
  <pre><code>Pattern A = Pattern.compile("(gct)|(gcc)|(gca)|(gcg)");
  Pattern C = Pattern.compile("(tgt) | (tgc)");
  Pattern D = Pattern.compile("(gat) | (gac)");
  </code></pre>
  
  <p>etc.</p>
  
  <p>However, I now realise that you need to make a matcher for EACH pattern and you can't use one matcher to search for ALL patterns; what is the best way for me to achieve what I am trying to do?  </p>