I have incoming data which is delimiter by a string token:
Data 1__##__Data Two__##__Third Data__##__4th Data__##__
I would like to split this by the delimiter __##__ to give:
Data 1
Data Two
Third Data
4th Data
I figured on looping and using this to get each data item in turn, but as a first stage to everything from the beginning to the nth item inclusive:
SELECT REGEXP_REPLACE( 'Data 1__##__Data Two__##__Third Data__##__4th Data__##__', '__##__.+', 1, 1 ) from dual;
The above gives the desired Data 1, however:
SELECT REGEXP_REPLACE( 'Data 1__##__Data Two__##__Third Data__##__4th Data__##__', '__##__.+', 1, 2 ) from dual;
expected to give Data1__##__Data Two instead gives the whole input string back unchanged.
Earlier I tried the following but this just returns blank:
SELECT REGEXP_SUBSTR( 'Data 1__##__Data Two__##__Third Data__##__4th Data__##__',
'(?!__##__)',
1, LEVEL )
FROM dual
CONNECT BY REGEXP_SUBSTR( 'Data 1__##__Data Two__##__Third Data__##__4th Data__##__',
'(?!__##__)',
1, LEVEL ) IS NOT NULL
This returns null.