Reputation: 3438
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');
Upvotes: 4
Views: 10375
Reputation: 461
You could also use the BTRIM function for this. Example:
BTRIM(title,'[]') as "title"
Cheers!
Upvotes: 7
Reputation: 12558
Not tested, but assuming that this is regular regex syntax.
UPDATE test_table SET title = regexp_replace(title, '\(|\)', '', 'g');
or
UPDATE test_table SET title = regexp_replace(title, '[()]', '', 'g');
Putting the () into []
means to look for each single character. Using the |
means "or", but you need to \
escape the () in that case.
Upvotes: 2