在postgresql中使用replace

时间:2014-07-09 06:49:12

标签: sql postgresql

我使用replace

进行以下SQL查询
SELECT 
            replace(
            replace(
            replace(
            replace(
            replace(email_text , 'This email is to notify you that for one or more records the Clearance has been Requested. Please follow the link below to go directly to this record.', '') 
              , ':', '</th>:<th>')  
              , '<BR/></th>','<BR/>') 
              , 'http</th>:<th>', 'http:') 
              , '</ul>', '</th></ul>') 
            INTO  v_result 
                FROM   record.notification  
                WHERE record_notification_id = p_recordnotification_id;

在上面的代码中我有

replace(email_text , 'This email is to notify you that for one or more records the Clearance has been Requested. Please follow the link below to go directly to this record.', '') 

现在,我想使用替换email_text与以&#39;此电子邮件&#39;开头的句子。以&#39;此记录结束。&#39; 而不是写完整的句子。 请建议。

1 个答案:

答案 0 :(得分:2)

使用正则表达式:

regex_replace(email_text, 'This email.*this record[.]', '')