title: preg_replace double replacement
body: <p>I'm getting some unexpected results from a regular expression, which is meant to be replacing the classname on a namespace. The replacement appears to happen twice, so that the classname getting replaced is duplicated (see example below).</p>
  
  <p>I've actually resolved the problem by changing the reg ex to match 1 or more (<code>+</code>) rather than 0 or more (<code>*</code>) which is actually more accurate for what I want.</p>
  
  <p>However, I'm a little confused as to why I was getting an issue in the first place.</p>
  
  <p>Here is an example of the problem:</p>
  
  <pre><code>$classns  = 'components\groups\GroupsController';
  $newclass = 'GroupsAccess';
  $classns = preg_replace('/[^\\\\]*$/', $newclass, $classns);
  echo $classns;
  </code></pre>
  
  <p>Result</p>
  
  <pre><code>components\groups\GroupsAccessGroupsAccess
  </code></pre>
  
  <p>Expected</p>
  
  <pre><code>components\groups\GroupsAccess
  </code></pre>
  
  <p>Is it possible that the * is matching a word boundary or something of that nature?</p>
  
  <p>The confusing part for me is that a preg_match using the same regex shows only one result, so it would appear to be something specific to how preg_match runs the regex.</p>
  
  <p>e.g.</p>
  
  <pre><code>preg_match('/[^\\\\]*$/', $classns, $m);
  var_dump($m);
  </code></pre>
  
  <p>Result</p>
  
  <pre><code>array(1) { [0]=&gt; string(12) "GroupsAccess" }
  </code></pre>