string str = "http://www.rczjp.cn/A/B/C/index.aspx?cid=11&sid=22"; Regex reg = new Regex(@"(?imn)(?<do>http://[^/]+/)(?<dir>([^/]+/)*([^/.]*$)?)((?<page>[^?.]+\.[^?]+)\?)?(?<par>.*$)"); MatchCollection mc = reg.Matches(str); foreach (Match m in mc) { Console.WriteLine(m.Groups["do"].Value); //http://www.rczjp.cn/ Console.WriteLine(m.Groups["dir"].Value); //A/B/C/ Console.WriteLine(m.Groups["page"].Value); //index.aspx Console.WriteLine(m.Groups["par"].Value); //cid=11&sid=22 } Console.Read();