title: How to use preg_replace to replace everything within slashes? (Only every other match is replaced)
body: <p>I am new to regular expressions, and I've been trying to use it with an url, but I can't get it to work.</p>
  
  <p>I have a string that is:</p>
  
  <blockquote>
    <p>/plugins/plugins/plugins/plugins/plugins/plugins/</p>
  </blockquote>
  
  <p>and I would like to replace all letters to the string "{char}" so that the string end up being:</p>
  
  <blockquote>
    <p>/{char}/{char}/{char}/{char}/{char}/{char}/</p>
  </blockquote>
  
  <p>I've tried this:</p>
  
  <pre><code>&lt;?php
      $pattern        = '#(/)([a-z\_]+)(/)#'; 
      $replacement    = '$1{char}$3'; 
      $string         = '/plugins/plugins/plugins/plugins/plugins/plugins/';
  
      echo preg_replace($pattern, $replacement, $string);
  ?&gt;
  </code></pre>
  
  <p>But this code is resulting in this:</p>
  
  <blockquote>
    <p>/{char}/plugins/{char}/plugins/{char}/plugins/</p>
  </blockquote>
  
  <p>What am I doing wrong?</p>