求正则?
ContractName='aaaaa',contractRole='Web master',CtUpdate='02/02/2012'update=now()
要求,把=后面的数据作为一个字符串返回,
string result = 'aaaaa','Web master','02/02/2012','now()'
谢谢!!
return_false不知道在吗????
------解决方案--------------------(?<=[^=]+=(['"]?))[^'"]+(?=\1)
------解决方案--------------------给你来个非正则的
string str = "ContractName='aaaaa',contractRole='Web master',CtUpdate='02/02/2012',update=now(),ssss='sdsass'";
var s= str.Split(',').Where(t => t.Trim() != "").Select(t => t.Split('=')[1]).ToArray();
------解决方案--------------------
C# code
string temp = "ContractName='aaaaa',contractRole='Web master',CtUpdate='02/02/2012',update=now(),ssss='sdsass'";
string[] result = Regex.Matches(temp,@"(?<=='?)[^',\s]+(?='|,|\s)").Cast<Match>().Select(a=>a.Value).ToArray();
/*
[0] "aaaaa" string
[1] "Web" string
[2] "02/02/2012" string
[3] "now()" string
[4] "sdsass" string
*/