title: Ignore duplicates in regex pattern
body: <p>I have a regex pattern that searches for words in a text file. How do I ignore duplicates?</p>
  
  <p>For instance, take a look at this code</p>
  
  <pre><code>$pattern = '/(lorem|ipsum|daboom|pahwal|ababaga)/i';
  $num_found = preg_match_all( $pattern, $string, $matches );
  
  echo "$num_found match(es) found!";
  echo "Matched words: " . implode( ',', $matches[0] );
  </code></pre>
  
  <p>If I have more than one say <em>lorem</em> in the article, the output will be something like this</p>
  
  <pre><code>5 matches found!
  Matched words: daboom,lorem,lorem,lorem,lorem
  </code></pre>
  
  <p>I want the pattern to only find the first occurrence, and ignore the rest, so the output should be:</p>
  
  <pre><code>2 matches found!
  Matched words: daboom,lorem
  </code></pre>