title: Manipulating regex matches directly in the regex
body: <p>I have a few regexes in an array and testing some strings against them. </p>
  
  <pre><code>$results = array();
  
  $testString = 'The distance is 0,1 km. It is above 200 m.';
  
  $regex = array(
    'distance' =&gt; '/The distance is (?P&lt;distance&gt;\d+) m\./',
    'distance' =&gt; '/The distance is (?P&lt;distance&gt;\d+(,\d+)?) km\./',
    'height' =&gt; '/It is above (?P&lt;height&gt;\d+) m\./'
    'height' =&gt; '/It is above (?P&lt;height&gt;\d+(,\d+)?) km\./'
  );
  
  foreach ($regex as $key =&gt; $reg) {
    if (preg_match($reg, $testString, $matches)) {
      $results[] = array('type' =&gt; $key, 'value' =&gt; $matches[$key]);
    }
  }
  </code></pre>
  
  <p>I want to store the results as "meters", but in the test string above, the "km"-regex is matched. </p>
  
  <p>Can I add some magic to the regex code, so it transforms the matched <code>0,1</code> into <code>100</code> (= match * 1000)?</p>
  
  <p>It would be perfect to do it right in the regex code, so I dont have to add exceptions into the PHP code.</p>
  
  <p>Thank you for your help! :)</p>
  
  <p>Wulf</p>