Oracle - Replace first occurrence of multiple values
<p>I would like to replace the first occurrence of multiple values in a string. Pls consider the following example :</p>

<p><strong>Input string :</strong> <code>a,a,a,b,b,c</code></p>

<p><strong>Values to be replaced :</strong> <code>a,b</code></p>

<p><strong>Expected Output :</strong> <code>,a,a,,b,c</code></p>

<p>Using the <code>|</code> operator doesn't work, as shown below :</p>

<pre><code>select regexp_replace('a,a,a,b,b,c','a|b',null,1,1) from dual;
</code></pre>

<p>Output : <code>,a,a,b,b,c</code> . This replaces only the first occurrence of <code>a</code>.</p>

<p>As an extension to this, if <code>a</code> is to be replaced more than once, then the second occurrence should also be replaced in the input : </p>

<p><strong>Input string</strong> : <code>a,a,a,b,b,c</code></p>

<p><strong>Values to be replaced :</strong> <code>a,b,a</code></p>

<p><strong>Expected Output :</strong> <code>,,a,,b,c</code></p>

<p>Is this achievable using <code>REGEXP_REPLACE</code> or through something else? If yes, how? Thanks in advance for your help!</p>