http://202.205.170.240/neie/Lists/keywords/PersonalViews.aspx?PageView=Personal&ShowWebPart={61E679E8-5970-4E8E-9B9F-200B4778644E}
怎么得到
61E679E8-5970-4E8E-9B9F-200B4778644E
要用lastindexof('{')我c#
不太熟

解决方案 »

  1.        string str = @"http://202.205.170.240/neie/Lists/keywords/PersonalViews.aspx?PageView=Personal&ShowWebPart={61E679E8-5970-4E8E-9B9F-200B4778644E}";        int i=str.LastIndexOf('{');
            string str1 = str.Substring(i + 1);
            string str2 = str1.Substring(0, str1.Length - 1);
      

  2. string s="fafdsafdas{61E679E8-5970-4E8E-9B9F-200B4778644E}fsafdsafa ";//首尾加了些乱七八糟的数据,测试INDEXOF及LASTINDEXOF.
    int i=s.IndexOf('{');
    int j=s.LastIndexOf('}');
    s=s.SubString(i,j-i+1);
      

  3. string str = "http://202.205.170.240/neie/Lists/keywords/PersonalViews.aspx?PageView=Personal&ShowWebPart={61E679E8-5970-4E8E-9B9F-200B4778644E}";
                string str2 = str.Substring(str.LastIndexOf('{'));
                string strvalue = str2.Substring(1, str2.Length - 1);
      

  4. string str = @"http://202.205.170.240/neie/Lists/keywords/PersonalViews.aspx?PageView=Personal&ShowWebPart={61E679E8-5970-4E8E-9B9F-200B4778644E}"; 
    string[] strA = str.split(new char[] {'{'});
    List<string> list = new List<string>();
    foreach(string s in strA)
    {
       if(s[s.Length - 1] == '}')
       {
          list.Add(s.Substring(0,s.Length - 1));
       }
    }
      

  5. [/Quote]string str = "http://202.205.170.240/neie/Lists/keywords/PersonalViews.aspx?PageView=Personal&ShowWebPart={61E679E8-5970-4E8E-9B9F-200B4778644E}";
                string str2 = str.Substring(str.LastIndexOf('{'));
                string strvalue = str2.Substring(1, str2.Length - 2);[/code]
      

  6. string str = "http://202.205.170.240/neie/Lists/keywords/PersonalViews.aspx?PageView=Personal&ShowWebPart={61E679E8-5970-4E8E-9B9F-200B4778644E}";
                string str2 = str.Substring(str.LastIndexOf('{'));
                string strvalue = str2.Substring(1, str2.Length - 2);
      

  7. 正则表达式
    Regex r = new Regex("{[A-Z0-9-]*}");
            Match m = r.Match("http://202.205.170.240/neie/Lists/keywords/PersonalViews.aspx?PageView=Personal&ShowWebPart={61E679E8-5970-4E8E-9B9F-200B4778644E}");
            Response.Write(m.ToString());
      


  8. //仅供参考
                String str = @"http://202.205.170.240/neie/Lists/keywords/PersonalViews.aspx?PageView=Personal&
                        ShowWebPart={61E679E8-5970-4E8E-9B9F-200B4778644E}";
                Regex objRegex = new Regex(@"(?im)(?<={)[-a-z0-9]+(?=})");            MatchCollection objMatches = objRegex.Matches(str);            int index = 0;                        foreach (Match objMatch in objMatches)
                {
                    Response.Write(String.Format("{0} : {1}<br />",index++,objMatch.Value));
                }            
      

类似问题 »