2014-07-09 40 views
0

取代我在使用替代使用PostgreSQL中

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下面的SQL查詢'這封電子郵件'以'此記錄'結尾。 ,而不是寫完整的句子。 請建議。

+1

Grah,爲什麼?你究竟在做什麼 - 從HTML中獲取純文本? –

回答

2

使用正則表達式:

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

這正是我想要的,謝謝 – ronan