Solved

replace string

Posted on 2011-02-11
6
255 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

816 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

10 Experts available now in Live!

Get 1:1 Help Now