Reputation: 139
I'm trying to remove annoying 'indexing' from a string in all columns. Downloaded from wikipedia, index was supposed to refer to the source.
What I managed to find is:
UPDATE
table_name
SET
column_name = REPLACE(column,old_text,new_text)
WHERE
condition
but it doesn't seem to be working - I'd need to use LIKE '%[%]%'
as old_text if 3 % would even work.
Any ideas? Thanks!
Upvotes: 0
Views: 325
Reputation: 1270061
I would go for:
update t
set column_name = regexp_replace(column_name, '\[[0-9]+\]', '')
where column_name ~ '\ [[0-9]+\]';
instead of just using replace()
.
Upvotes: 2