2017-09-26 35 views

回答

1

,如果你想使用substring with regular,採取星號方括號:

t=# SELECT substring('QUITAR1 *W01 - 123456/9* QUITAR2 ' from '%#"[*]%[*]#"%' for '#'); 
    substring 
------------------ 
*W01 - 123456/9* 
(1 row) 

所以得到你想要的:

t=# SELECT replace(substring('QUITAR1 *W01 - 123456/9* QUITAR2 ' from '%#"[*]%[*]#"%' for '#'),'*',''); 
    replace 
---------------- 
W01 - 123456/9 
(1 row) 

我正在使用替換,因爲在文本中有asterix可能無論如何會制動屏蔽

相關問題