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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

REGEXP_REPLACE - Replace every occurrence of the letter in the pattern

Karthick2003Dec 1 2008 — edited Jun 19 2013
I need a regular expression query to do the following

Input
'[karthick] account number is [10000010101] and my pin is [1919128]'
Output
'######## account number is ########### and my pin is #######'
In short any thing that is between [] should be replaced with #

I tried this.
SQL> with t
  2  as
  3  (
  4     select '[karthick] account number is [10000010101] and my pin is [1919128]' str
  5       from dual
  6  )
  7  select str, regexp_replace(str,'\[[[:alnum:]]+\]','#') str1
  8    from t
  9  /

STR
------------------------------------------------------------------
STR1
--------------------------------------------------------------------------------
[karthick] account number is [10000010101] and my pin is [1919128]
# account number is # and my pin is #
But i want all the letters inside [] to be replaced with #.


Thanks,
Karthick.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 17 2013
Added on Dec 1 2008
19 comments
27,029 views