/* PL/SQL */
declare
in_str constant varchar2(30) := 'foo' || chr(13) || 'bar' || chr(13);
out_str varchar2(30);
begin
dbms_output.put_line('in_str = ' || utl_raw.cast_to_raw(in_str));
select regexp_replace(in_str, chr(13) || '$', '') into out_str from dual;
dbms_output.put_line('out_str = ' || utl_raw.cast_to_raw(out_str));
end;
/
/* SQL */
select utl_raw.cast_to_raw('foo' || chr(13) || 'bar' || chr(13)) as BEFORE from dual;
select utl_raw.cast_to_raw(
regexp_replace('foo' || chr(13) || 'bar' || chr(13), chr(13) || '$', '')
) as AFTER from dual;
/* OUTPUT */
Session altered.
in_str = 666F6F0D6261720D
out_str = 666F6F0D626172
PL/SQL procedure successfully completed.
BEFORE
------------------------------------------------------------------------------
666F6F0D6261720D
AFTER
------------------------------------------------------------------------------
666F6F0D626172