find and replace the string within a column

From: Nicholas I <nicholas(dot)domnic(dot)i(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: find and replace the string within a column
Date: 2010-09-24 09:15:54
Message-ID: AANLkTi=yv6typUZDxhOjufJj2jua=OXb7cM8Lq86tRuv@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

the data in my table, have a substring enclosed in parenthesis,

1. i want to replace the string with the brackets to null or any other
value.
2. remove the contents within brackets.

Example:
table name person:

name
------------------------------------
Samuel (S/o Sebastin )
-------------------------------------

remove the word within the brackets.
the output should be , Samuel.

the below one help's me to find the data within the two brackets.

SELECT name,(REGEXP_MATCHES(name, E'\\(.+?\\)'))[1] from person;
regexp_matches
------------------------------------
(S/o Sebastin )
-------------------------------------

-Nicholas I

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Jayadevan M 2010-09-24 09:33:37 Re: find and replace the string within a column
Previous Message Tarlika Elisabeth Schmitz 2010-09-23 21:39:40 identifying duplicates in table with redundancies