string[] str = new string[] { "threadId=2", "time=2012-10-30", "sender=XXX", "receivers=XXX", "Msg=发发" }; for (int i = 0; i < str.Length; i++) { Match m = Regex.Match(str[i], @"=(.*)"); Console.WriteLine(m.Groups[1].Value); }
这个用正则取的,你也可以用楼上说的substring,但我觉着正则貌似更省事
我也来个 string[] str = new string[] { "threadId=2", "time=2012-10-30", "sender=XXX", "receivers=XXX", "Msg=发发" }; string s = string.Empty; for (int i = 0; i < str.Length; i++) { s = System.Text.RegularExpressions.Regex.Replace(str[i], @"[\s\S]*?=", ""); MessageBox.Show(s); }
string[] str = new string[] { "threadId=2", "time=2012-10-30", "sender=XXX", "receivers=XXX", "Msg=发发" };
for (int i = 0; i < str.Length; i++)
{
Match m = Regex.Match(str[i], @"=(.*)");
Console.WriteLine(m.Groups[1].Value);
}
string s = string.Empty;
for (int i = 0; i < str.Length; i++)
{
s = System.Text.RegularExpressions.Regex.Replace(str[i], @"[\s\S]*?=", "");
MessageBox.Show(s);
}