title: Increment a counter with regex in PHP
body: <p>I am trying to increment a counter at the end of a string in PHP. The counter is always between parenthesis at the end of the string and the rest can be literally anything, meaning there could even be something that looks like the counter (i.e. : a number between parenthesis), but has a different meaning and shouldn't be altered.</p>
  
  <p>Exemples :</p>
  
  <ol>
  <li><code>Foo (Bar) (666) (123)</code> : <code>Foo (Bar) (666)</code> is the main part and <code>123</code> is the counter. I want to get : <code>Foo (Bar) (666) (124)</code>. <code>(666)</code> looks like the counter but since it isn't located at the end of the string it isn't considered as such.</li>
  <li><code>Lorem ipsum dolor sit amet (1337)</code> : <code>Lorem ipsum dolor sit amet</code> is the main part and <code>1337</code> is the counter. I want to get : <code>Lorem ipsum dolor sit amet (1338)</code>.</li>
  </ol>
  
  <p>The exact implementation doesn't matter. I just would like to use a regex to match the main part and the counter so I could put them in variables, increment the counter and build back the string.</p>
  
  <p>I can easily match the counter with something like <code>\((\d*)\)$</code> but I can't figure out how to match the rest of the string.</p>
  
  <p>What regex could do the job ?</p>