Hi,
I am having scenario where I want to split a single string based on the new line character and append a tag.(If blank string in a line tags with empty string should be there)
eg-
Input =
'12 abc' || chr(10) || '3' || chr(10) ||chr(10) || '3'
Output=
<a>12 abc</a><a>3</a><a></a><a>3</a>
I have written a function to achieve this as follows
Declare
Str varchar2(1000) := '12' || chr(10) || '3' || chr(10) ||chr(10) || '3';
Outstr varchar2(2000);
Begin
For i in 1.. (regexp_count(str, chr(10)) + 1)
loop
Outstr := outstr || '<a>' || regexp_substr(str, '[^,]+||chr(10)',1,i) || '</a>';
End loop;
Dbms_output.put_line(outstr);
End;
But the result I get is
<a>12 abc
3
3</a><a></a><a></a><a></a>
How can I fix this issue(I dont want to use any select statement either only loop)?