2013-04-02 97 views
0

我需要 更換&nbsp   我的正則表達式是&nbsp([^;])正則表達式替換&NBSP與 

我更換 

我的代碼與

更換

<pre><code> 
<ul><b> </b>&nbsp</ul> 
<tr valign="top"><td width="144">&nbsp;United Kingdom</td><td width="144">&nbsp;Pound</td><td width="144">&nbsp;Pence</td></tr></pre></code> 

<pre><code> 
<ul><b> </b>&nbsp;/ul> 
<tr valign="top"><td width="144">&nbsp;United Kingdom</td><td width="144">&nbsp;Pound</td><td width="144">&nbsp;Pence</td></tr> 

它去除</ul></pre></code>

任何幫助的<標籤?

+3

哪種語言或工具,你正在使用正則表達式? –

+0

不需要RegEx。這可以通過簡單的字符串替換功能在每種語言中完成。 – HamZa

回答

0

使用環視

(?<=&nbsp)(?=[^;]) 

OR

(?<=&nbsp)(?!;) 

;

+0

當然是最有趣的答案。但是,對於每個角色,你都會回到第5位,所以不應該尋找性能:) – Loamhoof

+0

@Loamhoof是的,我同意你的看法。 – Anirudha

0

它可能是更好的捕捉到非取代它;性格和加入;它的前面。

搜尋字符串:

(&nbsp)([^;]) 

替換字符串:

\1;\2 
2

嘗試用前瞻

(&nbsp)(?!;)