Regexp_substr is not working as expected
<p>So, I have a piece of simple SQL like:</p>

<pre><code>select 
REGEXP_SUBSTR (randomcol, '[^|]+', 1, 2)
||'|'||       REGEXP_SUBSTR (randomcol, '[^|]+', 1, 3)
||'|'||       REGEXP_SUBSTR (randomcol, '[^|]+', 1, 4)
from table1 where ADDTL_DETAIL_INFO is not null and module_key='01-07-2016 00:00:00/2212/    1';
</code></pre>

<p>The idea is to get the pipe separated values present in the randomcol column where the value present is:</p>

<pre><code>~custom|HELLO1||HELLO3
</code></pre>

<p>So I need the values like HELLO1,whitespace (as there is no value between the second pipe and the third pipe) and HELLO3.</p>

<p>But when I ran the above query it returns as:</p>

<pre><code>HELLO1|HELLO3|
</code></pre>

<p>and the white space is gone. I need this white space to retain. So what am I doing wrong here?</p>