2014-01-24 33 views
2

希望你做得很好。我正在尋找一些關於跟隨的幫助。使用兩個字符串之間的函數

我有一個共享點列表表,其中有Key_documents列。此列包含嵌入DIV和HTML標記中的許多HTML代碼片段,如下所示。對於某些字符串值,編碼看起來不太好(這來自源系統)。我正試圖解決在查詢輸出的編碼問題。

數據表的Key_Documents

<a href="http://tarregsp01p/sites/Regulatory/NextDocs Document Library/VEGF Trap-Eye/Module 5 - Clinical/03 Study Reports/311523 (VIEW 2)/01 Study Report/311523-Report Body.pdf">Year 1 CSR</a></div> 

所需的輸出

<a href="http://tarregsp01p/sites/Regulatory/NextDocs%20Document%20Library/VEGF%20Trap-Eye/Module%205%20-%20Clinical/03%20Study%20Reports/311523%20(VIEW%202)/01%20Study%20Report/311523-Report%20Body.pdf">Year 1 CSR</a></div> 

請發現空的空間被編碼到%20上述

我想使用utl_url.escap e。這個問題是編碼所有的特殊字符,反過來破壞我的HTML代碼。

任何幫助?從技術上講,我想在上面的例子中使用utl_url.escape功能href=</a>

回答

0
select 
    id, 
    listagg(case mod(n,2) when 0 then utl_url.escape(substring) else substring end) 
    within group (order by n) string 
from 
(
    select 
    id, 
    n, 
    regexp_substr(string, '(.*?)'||chr(1), 1, n, '', 1) as substring 
    from 
    (select id, 
     regexp_replace(string, '(href=")(.*?)"', 
     '\1'||chr(1)||'\2'||chr(1)||'"')||chr(1) string 
    from your_table), 
    (select level n from dual connect by level < 999) 
    where 
    regexp_substr(string, '(.*?)'||chr(1), 1, n, '', 1) is not null 
) 
group by id 
order by id 

fiddle

相關問題