Solved

replace string

Posted on 2011-02-11
6
257 Views
Last Modified: 2012-06-27
Using regex_replace how can I modify strings with more than one condition.

example ..
In a column I want to change say any text with "ADMIN" to "Administrator"
and anything with say FP FINAL to FP Final - everything else stays as is.

Regards
0
Comment
Question by:philsivyer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 12

Expert Comment

by:enachemc
ID: 34870266
update table
set column=
case column like '%ADMIN%' then 'Administrator'
case column like '%FP FINAL%' then 'FP Final'
else column
end
0
 
LVL 74

Accepted Solution

by:
sdstuber earned 500 total points
ID: 34870274
you don't need or want regular expressions for this...


update yourtable set yourcolumn = replace(replace(yourcolumn,'ADMIN','Administrator'),'FP FINAL','FP Final')

but if you want to try you can change "replace" to "regexp_replace"   - it will work but it will be les efficient
0
 

Author Comment

by:philsivyer
ID: 34870279
Thanks
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 74

Expert Comment

by:sdstuber
ID: 34870667
unless I'm misunderstanding the requirement, I recommend NOT using the suggestion in
http:#34870266

for one, it's illegal syntax
two, if it did work

case column like '%ADMIN%' then 'Administrator'


that will change
     'This is an ADMIN account'
into
      'Administrator'

which doesn't seem correct,  similarly the other replace would also change all of the non-FP FINAL characters as well

0
 

Author Comment

by:philsivyer
ID: 34870760
Thanks
0
 

Author Closing Comment

by:philsivyer
ID: 34870766
Thanks
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question