oracle clob欄位去除html標籤

阿杜_ardo發表於2017-03-28

通過正規表示式的方式去除html標籤

select regexp_replace(content,'</?[^>]*>|nbsp;|&','') content from T_TEST_CONTENT_CONFIG t
order by status_date desc;


原始clob內容:

<p><spanstyle="font-family:宋體;">【某某公司】您有一條XX尚未領取!使用</span><spanstyle="font-family: Calibri;">8G</span><spanstyle="font-family: 宋體;">套餐</span><spanstyle="font-family: Calibri;">18</span><spanstyle="font-family: 宋體;">元檔可領取</span><spanstyle="font-family: Calibri;">50M</span><spanstyle="font-family: 宋體;">寬頻,</span><span style="font-family:Calibri;">18</span><span style="font-family:宋體;">元檔可領取</span><span style="font-family:Calibri;">10M</span><span style="font-family:宋體;">寬頻</span><span style="font-family:Calibri;">+</span><span style="font-family:宋體;">電視機頂盒。更多優惠詳詢</span><span style="font-family:Calibri;">30012</span><span style="font-family:宋體;">或寬頻預約電話</span><span style="font-family:Calibri;">158******</span><span style="font-family:宋體;">,諮詢是否滿足領取條件。</span><aname="_GoBack"></a></p><p>&nbsp;</p>


轉換後:

【某某公司】您有一條XX尚未領取!使用8G套餐18元檔可領取50M寬頻,18元檔可領取10M寬頻+電視機頂盒。更多優惠詳詢30012或寬頻預約電話158******,諮詢是否滿足領取條件。