title: java regex multiple patterns sequential matching
body: <p>I have a specific question, to which I couldn't find any answer online. Basically, I would like to run a pattern-matching operation on a text, with multiple patterns. However, I do not wish that the matcher gets me the result all at once, but instead that each pattern is called at different stages of the loop, at the same time that specific operations are performed on each of these stages. So for instance, imagining I have <code>Pattern1</code>, <code>Pattern2</code>, and <code>Pattern3</code>, I would like something like:</p>
  
  <pre><code> if (Pattern 1 = true) {
          delete Pattern1;
      } else if (Pattern 2 = true) {
          delete Pattern2;
      } else if (Pattern 3 = true) {
          replace with 'something;
      } .....and so on
  </code></pre>
  
  <p>(this is just an illustration of the loop, so probably the syntax is not correct, )</p>
  
  <p>My question is then: how can I compile different patterns, while calling them separately?
  (I've only seen multiple patterns compiled together and searched together with the help of AND/OR and so on..that's not what I'm looking for unfortunately) Could I save the patterns in an array and call each of them on my loop? </p>