日期:2014-05-17 浏览次数:20835 次
private DbParameter[] fun1(string str)
{
//string str = "a='a111' and b='222' and ccc=200";
var array = Regex.Matches(str, @"([\w_]+)=([""']?)(.*?)\2(?=\s
------解决方案--------------------
$)").OfType<Match>().Select(t => new { field = t.Groups[1].Value, value = t.Groups[3].Value }).ToArray();
if (array.Count() == 0)
return null;
DbParameter[] dbParameter = new DbParameter[array.Count()];
for (int i = 0; i < array.Count(); i++)
{
dbParameter[i] = new DbParameter(array[i].field, array[i].value);
}
return dbParameter;
}