Solved

replace string

Posted on 2011-02-11
6
253 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
  • 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 73

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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 73

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
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 shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now