By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
declare
l_example varchar2(32000);
begin
l_example :='some text,
)';
dbms_output.put_line(l_example);
l_example := regexp_replace(l_example, '(,\s*?'|| CHR(10)||' *)(\s*?\))', '\2', 1, 1,'m');
dbms_output.new_line;
dbms_output.put_line(l_example);
END;
/
1 rows affected
dbms_output:
some text,
)
some text)