ceshi
2012-02-04 16:53
323 查看
string Resault = content;
//清空代碼前後(普通代碼)
string pattern = @"<div class=\""cnblogs_code\""((?!</?div[^>]*>).|\n)*(((?'TAG'<div[^>]*>)((?!</?div[^>]*>).|\n)*)+((?'-TAG'</div>)((?!</?div[^>]*>).|\n)*)+)*(?(TAG)(?!))</div>";
Regex rgx = new Regex(pattern, RegexOptions.IgnoreCase);
MatchCollection matches = rgx.Matches(Resault);
string pattern1 = @"<pre.*>((?!</?div[^>]*>).|\n)*(((?'TAG'<div[^>]*>)((?!</?div[^>]*>).|\n)*)+((?'-TAG'</div>)((?!</?div[^>]*>).|\n)*)+)*(?(TAG)(?!))</pre>";
Regex rgx1 = new Regex(pattern1, RegexOptions.IgnoreCase);
MatchCollection matches1 = rgx1.Matches(Resault);
if (matches.Count > 0)
{
for (int id = 0; id < matches.Count; id++)
{
Resault = Resault.Replace(matches[id].Value, matches1[id].Value);
}
}
//清空代碼前後(普通代碼)
string pattern = @"<div class=\""cnblogs_code\""((?!</?div[^>]*>).|\n)*(((?'TAG'<div[^>]*>)((?!</?div[^>]*>).|\n)*)+((?'-TAG'</div>)((?!</?div[^>]*>).|\n)*)+)*(?(TAG)(?!))</div>";
Regex rgx = new Regex(pattern, RegexOptions.IgnoreCase);
MatchCollection matches = rgx.Matches(Resault);
string pattern1 = @"<pre.*>((?!</?div[^>]*>).|\n)*(((?'TAG'<div[^>]*>)((?!</?div[^>]*>).|\n)*)+((?'-TAG'</div>)((?!</?div[^>]*>).|\n)*)+)*(?(TAG)(?!))</pre>";
Regex rgx1 = new Regex(pattern1, RegexOptions.IgnoreCase);
MatchCollection matches1 = rgx1.Matches(Resault);
if (matches.Count > 0)
{
for (int id = 0; id < matches.Count; id++)
{
Resault = Resault.Replace(matches[id].Value, matches1[id].Value);
}
}
相关文章推荐
- ceshi
- ceshi
- ceshi
- Fatal error: Call to undefined function Think\C() in /var/www/html/ceshi.hzheee.com/think/ThinkPHP/Library/Think/Think.class.php on line 334 这个问题解决
- XIAO XUESHENG SHUXUECESHI
- ceshi
- Linux下采用普通用户ceshi身份自动启动Tomcat
- java异常之Couldn't get host name! [See nested exception: java.net.UnknownHostException: ceshi: ceshi:
- 解决 不可识别的数据库格式 'J:\ceshi_paixu\class.accdb'。
- ceshi 02
- ceshi
- aspx头部代码<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ceshi.aspx.cs" Inherits="SM_ceshi" %
- ceshi
- ceshi
- ceshi111
- ceshi
- ceshi
- ceshi
- ceshi
- ceshi