1、如details-1-2-3-4替换成details.aspx?id=123&p=4,最后一个'-'后面为p的值
2、搜索页面如何做伪静态?如searchresult.aspx?kwd=你好帅
------解决方案--------------------------------------------------------
- C# code
string str = "details-1-2-3-4"; Match m = new Regex(@"([^-]+)(?:-([^-.]+))*").Match(str); StringBuilder sb = new StringBuilder(); sb.Append(m.Groups[1].Value).Append(".aspx?id="); for (int i = 0; i < m.Groups[2].Captures.Count - 1; i++) sb.Append(m.Groups[2].Captures[i]); sb.Append("&p=").Append(m.Groups[2].Captures[m.Groups[2].Captures.Count - 1]); Console.WriteLine(sb.ToString()); Console.ReadLine();//details.aspx?id=123&p=4