From: | Jayadevan M <Jayadevan(dot)Maymala(at)ibsplc(dot)com> |
---|---|
To: | Nicholas I <nicholas(dot)domnic(dot)i(at)gmail(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org, pgsql-sql-owner(at)postgresql(dot)org |
Subject: | Re: find and replace the string within a column |
Date: | 2010-09-24 09:33:37 |
Message-ID: | OFF34DA862.E1543DC5-ON652577A8.00344354-652577A8.003484A7@ibsplc.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hello,
> 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 )
> -------------------------------------
>
Trying to work with your code -
update table set name =
substr( name,1,strpos(name, (REGEXP_MATCHES(name, E'\\(.+?\\)')) )-1 ) ||
substr( name,strpos(name, (REGEXP_MATCHES(name, E'\\(.+?\\)')) ) + 1
,char_length(name))
I am trying to find what is there before the pattern and after the pattern
and concatenating them . Please see documentation for proper use of
substr,strpos,cahr_length etc.
Regards,
Jayadevan
DISCLAIMER:
"The information in this e-mail and any attachment is intended only for
the person to whom it is addressed and may contain confidential and/or
privileged material. If you have received this e-mail in error, kindly
contact the sender and destroy all copies of the original communication.
IBS makes no warranty, express or implied, nor guarantees the accuracy,
adequacy or completeness of the information contained in this email or any
attachment and is not liable for any errors, defects, omissions, viruses
or for resultant loss or damage, if any, direct or indirect."
From | Date | Subject | |
---|---|---|---|
Next Message | James Kitambara | 2010-09-24 09:37:21 | Re: insert into help |
Previous Message | Nicholas I | 2010-09-24 09:15:54 | find and replace the string within a column |