日期:2014-05-18  浏览次数:20895 次

分离字符串
如何将 3c8779ff-185e-487e-8c39-65510c119827 从下面者段字符串中分离出来
BelongTo(USERS, "3c8779ff-185e-487e-8c39-65510c119827", "2d820eb3-ab6d-481a-b31c-7a4ff464834d")


------解决方案--------------------
string test = "BelongTo(USERS, \"3c8779ff-185e-487e-8c39-65510c119827\", \"2d820eb3-ab6d-481a-b31c-7a4ff464834d\")";
string[] temp = test.Split(',');
Console.WriteLine(temp[1].Replace("\"",""));
------解决方案--------------------
C# code
string test = "BelongTo(USERS, \"3c8779ff-185e-487e-8c39-65510c119827\", \"2d820eb3-ab6d-481a-b31c-7a4ff464834d\")";
Console.WriteLine(test.Split('"')[1]);
Console.ReadLine();

------解决方案--------------------
C# code
using System;
using System.Text.RegularExpressions;

class Test
{
  static void Main()
  {
    string s = @"BelongTo(USERS, ""3c8779ff-185e-487e-8c39-65510c119827"", ""2d820eb3-ab6d-481a-b31c-7a4ff464834d"")";
    string t = Regex.Match(s, @"\w+\(\w+,\s+\""([^""]+)\""").Groups[1].Value;
    Console.WriteLine(t);
  }
}