<!-- AspNetPager V7.0.2 for VS2005 & VS2008  Copyright:2003-2007  Webdiyer (www.webdiyer.com) --> 
<div id="Pager" style="text-align:right;"> 
<a disabled="disabled" style="margin-right:5px;">首页 </a> <a  disabled="disabled" style="margin-right:5px;">上一页 </a> <span  style="margin-right:5px;font-weight:Bold;color:red;">1 </span> <a  href="javascript:__doPostBack('Pager','2')" style="margin- right:5px;">2 </a> <a href="javascript:__doPostBack('Pager','3')"  style="margin-right:5px;">3 </a> <a  href="javascript:__doPostBack('Pager','2')" style="margin- right:5px;">下一页 </a> <a href="javascript:__doPostBack('Pager','4')"  style="margin-right:5px;">末页 </a> 
</div> 
<!-- AspNetPager V7.0.2 for VS2005 & VS2008 End --> 要求:移除外层的div,将javascript:__doPostBack('Pager','2')替换成诸如:http://www.sohu.com/2 
结果: 
<div id="Pager" style="text-align:right;"> 
<a disabled="disabled" style="margin-right:5px;">首页 </a> <a  disabled="disabled" style="margin-right:5px;">上一页 </a> <span  style="margin-right:5px;font-weight:Bold;color:red;">1 </span> <a  href="http://www.sohu.com/2" style="margin- right:5px;">2 </a> <a href="http://www.sohu.com/3"  style="margin-right:5px;">3 </a> <a  href="http://www.sohu.com/2" style="margin- right:5px;">下一页 </a> <a href="http://www.sohu.com/4"  style="margin-right:5px;">末页 </a> 
</div>

解决方案 »

  1.   

    aspnetpager可支持URL REWRITE方式,同时官网上也有源代码下载,你可以从源代码中去掉版权信息(但是不建议你这样做)
      

  2.   

    通过正则表达式替换href里内容
     string output = Regex.Replace(input,"(?is)(?<=<(a)\b.*?(href)="")javascript:__doPostBack","http://www.sohu.com/2 ");参考
      

  3.   

    try...string result = Regex.Replace(yourStr, @"(?i)<!--\s*AspNetPager[^>]*>", "");
    result = Regex.Replace(result, @"(?i)javascript:__doPostBack\('Pager','(\d+)'\)", @"http://www.sohu.com/$1");
    richTextBox2.Text = result;
      

  4.   

    移除外层的div之后
    result = Regex.Replace(yourStr, @"(?i)<!--\s*AspNetPager[^>]*>", "");将javascript:__doPostBack('Pager','2')替换成诸如:http://www.sohu.com/2 
    result = Regex.Replace(result, @"(?i)javascript:__doPostBack\('Pager','(\d+)'\)", @"http://www.sohu.com/$1");
    顶,过客。。
      

  5.   


    这个是忽略大小写的匹配模式,在.NET中,等价于RegexOptions.IgnoreCase参数
      

  6.   

    下载PilotEdit 2.5, http://topic.csdn.net/u/20090512/21/99628cbd-3c70-4d29-91ff-1962f01e7a7c.html用下面的正则表达式查找替换:
    查找:javascript:__doPostBack[ ]*\('Pager','?'\)
    替换为:http://www.sohu.com/%04
    假设原始文件为:
    <div id="Pager" style="text-align:right;">
    <a disabled="disabled" style="margin-right:5px;">首页 </a> <a  disabled="disabled" style="margin-right:5px;">上一页 </a> <span  style="margin-right:5px;font-weight:Bold;color:red;">1 </span> <a  href="javascript:__doPostBack('Pager','2')" style="margin- right:5px;">2 </a> <a href="javascript:__doPostBack('Pager','3')"  style="margin-right:5px;">3 </a> <a href="javascript:__doPostBack ('Pager','4')" style="margin-right:5px;">4 </a> <a  href="javascript:__doPostBack('Pager','2')" style="margin- right:5px;">下一页 </a> <a href="javascript:__doPostBack('Pager','4')"  style="margin-right:5px;">末页 </a>
    </div>将被转换为:
    <div id="Pager" style="text-align:right;">
    <a disabled="disabled" style="margin-right:5px;">首页 </a> <a  disabled="disabled" style="margin-right:5px;">上一页 </a> <span  style="margin-right:5px;font-weight:Bold;color:red;">1 </span> <a  href="http://www.sohu.com/2" style="margin- right:5px;">2 </a> <a href="http://www.sohu.com/3"  style="margin-right:5px;">3 </a> <a href="http://www.sohu.com/4" style="margin-right:5px;">4 </a> <a  href="http://www.sohu.com/2" style="margin- right:5px;">下一页 </a> <a href="http://www.sohu.com/4"  style="margin-right:5px;">末页 </a>
    </div>