title: Combine multiple match regular expression into one and get the matching ones
body: <p>I have a list of regular expressions:</p>
  
  <pre><code>suresnes|suresne|surenes|surene
  pommier|pommiers
  ^musique$
  ^(faq|aide)$
  ^(file )?loss( )?less$
  paris
  faq                              &lt;&lt;&lt; this match twice
  </code></pre>
  
  <p>My use case is that each pattern which got a match display a link to my user,
  so I can have multiple pattern matching.</p>
  
  <p>I test thoses patterns against a simple string of text "live in paris" / "faq" / "pom"...</p>
  
  <p>The simple way to do it is to loop over all the patterns with a <code>preg_match</code>, but I'm will do that a lot on a <strong>performance critical page</strong>, so <strong>this look bad to me</strong>.</p>
  
  <p>Here is what I have tried: combining all thoses expressions into one with group names:</p>
  
  <pre><code>preg_match("@(?P&lt;group1&gt;^(faq|aide|todo|paris)$)|(?P&lt;group2&gt;(paris)$)@im", "paris", $groups);
  </code></pre>
  
  <p>As you can see, each pattern is grouped: <code>(?P&lt;GROUPNAME&gt;PATTERN)</code> and they are all separated by a pipe <code>|</code>. </p>
  
  <p>The result is not what I expect, as only the first group matching is returned. Look like when a match occurs the parsing is stopped.</p>
  
  <p>What I want is the list of all the matching groups. <code>preg_match_all</code> does not help neither.</p>
  
  <p>Thanks!</p>