分离字符串
如何将 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); }}