string url = @"<a disabled=""disabled"" style=""margin-right:5px;"">首页</a><a disabled=""disabled"" style=""margin-right:5px;"">上一页</a><span class=""cpb"" style=""margin-right:5px;"">1</span><a href=""WriteAndUpByftp.aspx?page=2"" class=""paginator"" style=""margin-right:5px;"">2</a><a href=""WriteAndUpByftp.aspx?page=3"" class=""paginator"" style=""margin-right:5px;"">3</a><a class=""paginator"" href=""WriteAndUpByftp.aspx?page=2"" style=""margin-right:5px;"">下一页</a><a class=""paginator"" href=""WriteAndUpByftp.aspx?page=3"" style=""margin-right:5px;"">尾页</a>
";
string pattern = @"";//正则我应怎样写?
Regex rgx = new Regex(pattern);
string a = rgx.Replace(url,"");//这里怎么写?
Response.Write(a);我需要将所有WriteAndUpByftp.aspx?page=1 WriteAndUpByftp.aspx?page=2……等WriteAndUpByftp.aspx?page开头的替换成如aabb1.htm aabb2.htm……这样的语名,再比如:
WriteAndUpByftp.aspx?page=1 ——aabb1.htm
WriteAndUpByftp.aspx?page=2——aabb2.htm
WriteAndUpByftp.aspx?page=3——aabb3.htm
解决方案 »
- 关于网页QQ的一个问题
- lable控件显示文档
- 浏览器缓存的问题
- 关于Infragistics的WebTree的问题?
- 如何将DataSet.Table["myTable"] 中的数据存进一个新表?
- 我想问下。.net中能不能这么写 protected System.Web.UI.WebControls.iframe mainframe;
- 在将 varchar 值 '矿泉水' 转换成数据类型 int 时失败。 ??
- 请问:VB.NET中如何根据控件的ID(字符串形式)得到该控件(的引用)?
- 请教一下,为什么服务器组件(例如:listbox )怎么只有 ListBox_SelectedIndexChanged 方法?
- 我做了一个控件,如果打cab包,怎么把它加到页面中,怎么调用?先谢谢了
- 求一JAVASCRIPT的事件的动态绑定响应函数问题?
- asp.net后台代码(.aspx.cs文件)里面怎么获取JS里面定义的函数
string a = Regex.Replace(url,pattern,"aabb$1.htm");
string oldUrl = HttpContext.Current.Request.RawUrl;
string pattern = @"^(.+)News(d+).html(?.*)*$";
string replace = "$1NewsDetails.aspx?NID=$2";
if (Regex.IsMatch(oldUrl, pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled))
{
string newUrl = Regex.Replace(oldUrl, pattern, replace,
RegexOptions.Compiled | RegexOptions.IgnoreCase);
this.Context.RewritePath(newUrl);
}