string strCommand="create proc test as select *from t1"
if (!Regex.IsMatch(strCommand, "create proc"))
{}
if (!Regex.IsMatch(strCommand, "create procedure"))
{}
if (!Regex.IsMatch(strCommand, "Create procedure"))
{}如果strCommand存在create proc,create procedure,drop proc,drop procedure,
等只要是这样的词组.注意不区分大小写!类似下面的都不可以执行
Create Proc
Create Procedure
cReate ProcEdure
等等!
if (!Regex.IsMatch(strCommand, "create proc"))
{}
if (!Regex.IsMatch(strCommand, "create procedure"))
{}
if (!Regex.IsMatch(strCommand, "Create procedure"))
{}如果strCommand存在create proc,create procedure,drop proc,drop procedure,
等只要是这样的词组.注意不区分大小写!类似下面的都不可以执行
Create Proc
Create Procedure
cReate ProcEdure
等等!
richTextBox2.Text = "符合要求";
else
richTextBox2.Text = "不符合要求";
{}
string str = "drop proc sfsfdsf";
Console.WriteLine(Regex.IsMatch(str, @"(create|drop)\s+proc(edure)?", RegexOptions.IgnoreCase));
string strCommand = "create proc test as select *from t1";
Regex reg = new Regex(@"create proc|create procedure|drop proc|drop procedure", RegexOptions.IgnoreCase);
if (reg.Match(strCommand).Success) return;
{
string sql = "drops procedure test as select *from t1";
Console.WriteLine(IsSqlOk(sql));
Console.ReadLine();
} public static bool IsSqlOk(string sql)
{
Regex regex =
new Regex("(create proc)|(create procedure)|(drop proc)|(drop procedure)", RegexOptions.IgnoreCase);
return regex.IsMatch(sql);
}