Question : how to replace/ remove text

Hi,

I have a table say Table_A which has 2 columns say page_id,  clob column say column_c which has bunch of say html etc pages. One record whose page_id is '111' has a  login html page within the column_c. The login page has some entry at the top like

abc#222 ;(Format: NNN)


I want to remove that entry using update or replace with etc query commands.( not sure which is best command to use as this is small text entry within huge login html page)

How can i do something like, wherever I find the text  say

abc#222   (Format: NNN)


within login html page clob column of a table Table_A i want to replace it with say
 

abc#333   (Format: NNN)


 or prefarably with nothing, empty space like say ' '. How can I achieve it.
When I write update query like
update  Table_A   set  column_c = '

abc#333 ;(Format: NNN)

' where column_c like '

abc#222   (Format: NNN)

'
SqlDeveloper complaining about & and single quotes etc. I am not sure how to achieve this. Please advise
Any sample code, ideas, resources, links highly appreciated. Thanks in advance.

Answer : how to replace/ remove text

You could use the simple REPLACE() function, but for the type of stuff you are doing you will most likely want a more general pattern, not just for #222 but any pattern of that type. If so, use regular expressions.

Use REGEXP_REPLACE() function
1:
2:
3:
4:
5:
6:
7:
8:
9:
-- specific regex for just #222 pattern
select regexp_replace(column_c, '

abc#222   \(Format: NNN\)

', '

abc#333   \(Format: NNN\)

') from table_a; -- More general purpose for any number in the source pattern, note the \d+ regex select regexp_replace(column_c, '

abc#(\d+)   \(Format: NNN\)

', '

abc#333   \(Format: NNN\)

') from table_a; -- And an update to do the replace update table_a set column_c = regexp_replace(column_c, '

abc#(\d+)   \(Format: NNN\)

', '

abc#333   \(Format: NNN\)

');
Open in New Window Select All
Random Solutions  
 
programming4us programming4us