?
Solved

replace string

Posted on 2011-02-11
6
Medium Priority
?
259 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 2000 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
Via a live example, show how to take different types of Oracle backups using RMAN.
Suggested Courses

777 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