首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

分离字符串解决方案

2012-02-01 
分离字符串如何将 3c8779ff-185e-487e-8c39-65510c119827从下面者段字符串中分离出来BelongTo(USERS, 3c8

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

热点排行