2015-12-28 9 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

你试过它的工作..它非常简单.... –