Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

REGEXP_REPLACE (DBMS_REACT.REGEXP): Need to replace all but the last 4 characters of variable length

2784393Oct 29 2014 — edited Oct 29 2014

Hi there,

We have a column which contains variable length string/varchar2 values.

We want to mask all but the last 4 characters and preserve the length.

Really we are using the DBMS_REACT.REGEXP which underneath the scenes is equivalent to REGEXP_REPLACE (I believe ).

This would be easy if Oracle supported negative lookaheads (e.g. in Java String.replaceAll(".(?!.{0,3}$)", "X")); returns exactly what I need

How can I achieve this?

Thanks

Pat

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 26 2014
Added on Oct 29 2014
7 comments
1,559 views