110,536
社区成员
发帖
与我相关
我的任务
分享
bool IsExistID(string str)
{
string s=str;
int start, end;
while(true) //循环找"(.....)"
{
start = s.IndexOf('(');
if (start == -1)
break;
end = s.IndexOf(')', start);
s=s.Remove(start, end - start + 1); //将"(.....)"删掉
}
if (s.IndexOf("id")>=0) //查看剩下的主语句中是否有"id"
return true;
else
return false;
}
bool IsExistID(string str)
{
string s=str;
int start, end;
while(true) //循环找"(.....)"
{
start = s.IndexOf('(');
if (start == -1)
break;
end = s.IndexOf(')', start);
s=s.Remove(start, end - start + 1); //将"(.....)"删掉
}
if (s.IndexOf("id")>=0) //查看剩下的主语句中是否有"id"
return true;
else
return false;
}
string strOQL = "select name, owner.id from account where id = '1234567890'";
string result = Regex.Replace(yourStr, @"\(((\((?<o>)|\)(?<-o>)|[^()])*(?(o)(?!)))\)|\bfrom\b[\s\S]*$", "", RegexOptions.IgnoreCase);
if (Regex.IsMatch(result, @"\b(?<!\.)id\b"))
MessageBox.Show("包含");
else
MessageBox.Show("不包含");
string strOQL = "select name, owner.id from account where id = '1234567890'";
string result = Regex.Replace(strOQL, @"\(((\((?<o>)|\)(?<-o>)|[^()])*(?(o)(?!)))\)", "");
result = Regex.Replace(result, @"\bfrom\b[\s\S]*$", "", RegexOptions.IgnoreCase);
if (Regex.IsMatch(result, @"\b(?<!\.)id\b"))
MessageBox.Show("包含");
else
MessageBox.Show("不包含");
string strOQL = "select name, owner.id from account where id = '1234567890'";
string result = Regex.Replace(strOQL, @"\(((\((?<o>)|\)(?<-o>)|[^()])*(?(o)(?!)))\)", "");
result = Regex.Replace(result, @"where[\s\S]*$", "", RegexOptions.IgnoreCase);
if (Regex.IsMatch(result, @"\b(?<!\.)id\b"))
MessageBox.Show("包含");
else
MessageBox.Show("不包含");
string strOQL = "select name, country, city, (select id, firstname, lastname from contacts), id, (select id, name, amount from opportunities) from account where name like '%a%'";
string result = Regex.Replace(strOQL, @"\(((\((?<o>)|\)(?<-o>)|[^()])*(?(o)(?!)))\)", "");
if (Regex.IsMatch(result, @"\bid\b"))
MessageBox.Show("包含");
else
MessageBox.Show("不包含");