[code=C#]C# codestring strCommand="create proc test as select *from t1"
 
 if (!Regex.IsMatch(strCommand, "create proc"))
   {}
 if (!Regex.IsMatch(strCommand, "create procedure"))
[code] 如果strCommand存在
create proc,
create procedure,
drop proc,
drop procedure, create table 
alter table 
drop table create function 
alter function 
drop function只要是这些的词组. 注意以上无alter proc注意不区分大小写! 
最重要的是:
如果是create table # 或create table ## 或drop table #,drop table ##是可以执行!

解决方案 »

  1.   

    create table 和 create table #区别在哪?或者说如何区分
      

  2.   

    create table Tb(t001 int)   --不可以执行
    create table #Tb(t001 int)  --可以执行 
    create table ##Tb(t001 int) --可以执行 
      

  3.   

    alter table 没有这样的限制是吧if (!Regex.IsMatch(yourStr, @"(create|drop)\s+(proc(edure)?\b|table\s+(?!#)|function)|alter\s+(table|function)\b", RegexOptions.IgnoreCase))
        richTextBox2.Text = "符合要求";
    else
        richTextBox2.Text = "不符合要求";
      

  4.   

    过客的正则是我目前在csdn见过的最厉害的一个