Q:

Print all characters after every 3rd occurrence of comma in oracle

I have a string as "12as3,45we6,7we89,101112,131415,3234,1234" and want to write a oracle regex function or a SQL to print all the characters after every 3rd occurrence of comma (,) .
So the Output for this should be 
12as3,45we6,7we89
101112,131415,3234
1234

I have tried regex but it is only printing the first occurrence.
 SELECT NVL(
  SUBSTR('12as3,45we6,7we89,101112,131415,3234,1234', 1,
  INSTR('12as3,45we6,7we89,101112,131415,3234,1234',',',1,3) -1),
 '12as3,45we6,7we89,101112,131415,3234,1234')
FROM dual;

OutPut is
 12as3,45we6,7we89
I also tried this but it is printing after every comma.
with t as (
       select '12as3,45we6,7we89,101112,131415,3234,1234' as str from dual
      )
select  extractvalue(value(x), '/b') x
from  t,
    table(
          xmlsequence(
                      xmltype('<a><b>' || replace(str, ',', '</b><b>') || 
 '</b></a>' ).extract('/*/*')
                     )
             ) x
    /

Is there any way without using procedure of function, we can write in a select statement in Oracle.

A:

Here's one option, which uses a function. 
The idea is: 

split input string into rows
concatenate its pieces (it is one) by 3 in a group, separated by a comma
if it is the 3rd piece (see the MOD function), separate them by the line-feed character (CHR(10)) (it is the splitter)

SQL> create or replace function f_split (par_str in varchar2)
  2    return varchar2
  3  is
  4    l_str varchar2(200);
  5  begin
  6    for cur_r in (select mod(row_number() over (order by null), 3) rn_mod,
  7                         case when mod(row_number() over (order by null), 3) = 0 then chr(10)
  8                              else ','
  9                         end splitter,
 10                         regexp_substr(par_str, '[^,]+', 1, level) one
 11                  from dual
 12                  connect by level <= regexp_count(par_str, ',') + 1
 13                 )
 14    loop
 15      l_str := l_str || cur_r.one || cur_r.splitter;
 16    end loop;
 17
 18    return (l_str);
 19  end;
 20  /

Function created.

SQL> select f_split('12as3,45we6,7we89,101112,131415,3234,1234') result from dual;

RESULT
--------------------------------------------------------------------------------
12as3,45we6,7we89
101112,131415,3234
1234,

SQL>

Why not a simple SQL, which utilizes the same code? Because of this:
SQL> with test (col) as
  2    (select '12as3,45we6,7we89,101112,131415,3234,1234' from dual),
  3  split_me as
  4    (select row_number() over (order by null) rn,
  5            case when mod(row_number() over (order by null), 3) = 0 then chr(10)
  6                 else ','
  7            end splitter,
  8            regexp_substr(col, '[^,]+', 1, level) one
  9     from test
 10     connect by level <= regexp_count(col, ',') + 1
 11    )
 12  select listagg(one, splitter) within group (order by rn) result
 13  from split_me;
select listagg(one, splitter) within group (order by rn) result
                    *
ERROR at line 12:
ORA-30496: Argument should be a constant.

SQL>

I don't know how to fix that.

