2012-12-14 63 views
0

我對於正則表達式有點新,如果你能幫助我理解如何使用正則表達式替換 轉義字符回到文字html字符串,我真的很感激它。 我嘗試使用string.replace,它只取代代碼的某些部分不是全部。如何用正則表達式替換這個html

ex:string.replace("&lt;","<") ; //這個工作方式,但只在一行上,當它成爲一個循環時,這是一個問題,對於那些熟悉代碼的人來說,是的,這是一個SP博客代碼,SP將html文字標記逃脫chars。

<div class="ExternalClass2BF55814E98A409296EC90A2605D7D74"> 
    <div>&ltiframe src=&quot 
    <a href=http://player.vimeo.com/video/32001208?portrait=0&ampampbadge=0> 
      http://player.vimeo.com/video/32001208?portrait=0&ampampbadge=0 
    </a>&quot; 
    width=&quot;420&quot; height=&quot;281&quot; frameborder=&quot0&quot 
    webkitAllowFullScreen mozallowfullscreen allowFullScreen&gt&lt/iframe&gt; 
    </div> 
</div> 
+0

與string.replace()在.NET替換所有實例。將這些生產線聯合起來,並批量更換。 – Lloyd

+0

謝謝你的作品! – PinoyDev

回答

0

如果你的字符串是編碼HTML的,你可能會更好地運行它通過Server.HtmlDecode()。這會將其轉換回HTML。

'' In VB 
    Dim myHtml as String = Server.HtmlDecode(YourConcatonatedEncodedHTML) 

    // in C# 
    string myHtml = Server.HtmlDecode(YourConcatonatedEncodedHTML); 
+0

謝謝Darren,這個作品也是 – PinoyDev