http://localhost:18345/Admin/admin_top.aspx我要截取最后面的admin_top.aspx如何截取?我记得以前有个很简单的方式 suString(xx.LastIndexOf("/"),+1);类似这样的写法 在后面+1 就可以直接获取截取后面的所有字符了。怎么想都想不起来了,  现在求教了~~~~

解决方案 »

  1.   

    string str = "http://localhost:18345/Admin/admin_top.aspx";
    string str1 = str.Substring(str.LastIndexOf('/') + 1);
      

  2.   


     string s = "http://localhost:18345/Admin/admin_top.aspx";
                    int i= s.LastIndexOf("/");
                    s = s.Substring(i+1, s.Length - i-1 );
                    Response.Write(s);
    //结果:admin_top.aspx
      

  3.   

    1楼正确还可以。string str = "http://localhost:18345/Admin/admin_top.aspx";
          string[] s = str.Split('/');
          string a = s[s.Length - 1];
      

  4.   

    Regex.Match("http://localhost:18345/Admin/admin_top.aspx","[^/]+$").Value
      

  5.   

    string str = "http://localhost:18345/Admin/admin_top.aspx";
    string str1 = str.Substring(str.LastIndexOf('/') + 1);
    这样也简单
      

  6.   

    说错!Request.Url取不到admin_top.aspx这个
    用System.IO.Path.GetFileName