PHP preg_match doesn't match list separated with commas
<p>Here's my users list</p>

<pre><code>james,john,mark,luke,

james,john,mark,luke,mary,david
</code></pre>

<p>I want to remove the repeated part and retain the remaining.</p>

<p>So here's my code</p>

<pre><code>$old   = 'james,john,mark,luke,';
$users = 'james,john,mark,luke,mary,david';

// Replace , with |
$expr = rtrim(preg_replace('/\,/', '|', $old), '|');

$newstr = preg_replace("/$expr/i", '', $users);

echo $newstr;
</code></pre>

<p>Output</p>

<blockquote>
  <p>,,,,mary,david</p>
</blockquote>

<p>I want</p>

<blockquote>
  <p>mary,david,</p>
</blockquote>