Regex reg = new Regex(@"(['""]?/Topic/2008/SuperModel/)([^/]*)(.aspx)");
if (reg.IsMatch(RawUrl))
{
Match m = reg.Match(RawUrl);
RawUrl = m.Groups[1].Value + "SuperModelView.aspx?ID=" + com.Common.YY_user.GetUserID(m.Groups[2].Value);
isMatch = true;
}
这里是我的正则改写URL
其中的
if (reg.IsMatch(RawUrl))
{
Match m = reg.Match(RawUrl);感觉这里进行了两次Match
要怎么来进行优化代码呢谢谢
if(m.Success)
{
RawUrl = m.Groups[1].Value + "SuperModelView.aspx?ID=" + com.Common.YY_user.GetUserID(m.Groups[2].Value);
isMatch = true;
}
如果是我写href=['"]?/topic/2008/super.*?>(.*?)\.as
-------------------------------------------------------------
作者:hackztx [别急→慢慢来→总会好的]
日期:2008-07-14 13:55:47
参数:无
简介:C# regex
-------------------------------------------------------------
*/
(['""]?/Topic/2008/SuperModel/)([^/]*)(.aspx)分这么多组干什么啊??(.aspx)完全没有意义常量使用过长 c/2008/supermodel/(.*?)\.aspx
如果是我写href=['"]?/topic/2008/super.*?>(.*?)\.as