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#
不太熟
怎么得到
61E679E8-5970-4E8E-9B9F-200B4778644E
要用lastindexof('{')我c#
不太熟
string str1 = str.Substring(i + 1);
string str2 = str1.Substring(0, str1.Length - 1);
int i=s.IndexOf('{');
int j=s.LastIndexOf('}');
s=s.SubString(i,j-i+1);
string str2 = str.Substring(str.LastIndexOf('{'));
string strvalue = str2.Substring(1, str2.Length - 1);
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));
}
}
string str2 = str.Substring(str.LastIndexOf('{'));
string strvalue = str2.Substring(1, str2.Length - 2);[/code]
string str2 = str.Substring(str.LastIndexOf('{'));
string strvalue = str2.Substring(1, str2.Length - 2);
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());
//仅供参考
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));
}