-1
我在做C#中的字符串匹配,我必須將HTML和.aspx
頁面轉換成純文本格式(如瀏覽器視圖文本),在那個HTML頁面我有<style>
,<javascript>
和等我使用Regex.Replace
方法。ASP.NET正則表達式控制
//Removing JavaScripts
str = Regex.Replace(str, "<script.*?>.*?</script>", "", RegexOptions.Singleline);
//For Link Title
string regex = @"(?<=<title.*>)([\s\S]*)(?=</title>)";
Regex ex = new Regex(regex, RegexOptions.IgnoreCase);
string title = ex.Match(str).Value.Trim();
//Removing Html Tags
str = System.Text.RegularExpressions.Regex.Replace(str, "<.*?>", "");
str = str.Replace("\r\n", "");
你的意思是你要顯示它渲染/解析就像一個瀏覽器呢? – 2011-03-03 09:56:05
我不真的關注你的問題,你可以擴展它嗎?你提到你正在使用regex.replace,你有這個問題嗎? – Fishcake 2011-03-03 09:57:24
@Uw概念: - 是的。 – vasmay 2011-03-03 09:58:00