2015-12-28 47 views
1

我有一個像如何使用正則表達式

0||||0||||6567||||0 

我想用空字符串 取代0字符串所以匹配0我有以下的正則表達式使用更換一組值設置爲空字符串串

(?:^(?<zero>0)\||\|(?<zero>0)\||\|(?<zero>0)$) 

現在我想輸出

emptystring||||emptystring ||||6567||||emptystring 
+0

['\ B0 \ B'通過更換' ''']( https://regex101.com/r/kZ9oP4/1) – Tushar

+0

不是每個數字都是0 –

+0

@PriteshChhunchha你嘗試過嗎? –

回答

0

只需使用單詞邊界..

正則表達式:

\b0\b 

(?<![^|])0(?![^|]) 

替換:

emptystring 

DEMO

+0

你試過它的工作..它非常簡單.... –