title: Preg_replace to Preg_replace All
body: <p>Someone was kind enough to help me out with a regex for a very specific use, but my only problem now, is that the regex only replaces <strong>one</strong> instance of the match, and not all <em>matches</em> (which is the goal).</p>
  
  <p>I would like <strong>every</strong> instance of the <code>&lt;SPAN&gt;</code> with the "stylish-blue-button" class found here :</p>
  
  <pre><code>&lt;span class="stylish-blue-button"&gt;
     &lt;span style="display:none;"&gt;[data-user="12345" data-userId="678910"]&lt;/span&gt;
       John Smith
     &lt;span style="display:none;"&gt;[/]&lt;/span&gt;
  &lt;/span&gt;
  ...Blablabla some other text...
  </code></pre>
  
  <p>To become this :</p>
  
  <pre><code>[data-user="12345" data-userId="678910"]John Smith[/] ...Blablabla some other text...
  </code></pre>
  
  <p>To do so, I was provided with this preg_replace :</p>
  
  <pre><code>preg_replace('~\[(data-user="\d+")\h+(data-userId="\d+")\]\s*(.+?)\s*\[/\]\s*(.*)~s', '&lt;span $1 $2&gt;$3&lt;/span&gt;$4', trim(strip_tags($string)));
  </code></pre>
  
  <p>Now this works and it's wonderful, but it only replaces one instance.</p>
  
  <p><strong>Question :</strong> Would I have to drastically alter/change my approach for it to do so, or would it be a small modification?</p>
  
  <p>Thank you very much.</p>