Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove brackets from postgres table column but keep words inside them

I have a title column which contains some words within brackets. I would like to remove the brackets but keep the words which are currently inside them by using regexp_replace. I tried this but it didn't seem to work. There is still brackets in the column.

UPDATE test_table SET title = regexp_replace(title, '()', '', 'g');
like image 573
neilH Avatar asked Sep 02 '25 02:09

neilH


1 Answers

You could also use the BTRIM function for this. Example:

BTRIM(title,'[]') as "title"

Cheers!

like image 111
Joseph L. Avatar answered Sep 05 '25 12:09

Joseph L.