string test = "select * from testtable where id in(select id form table where tid=1)";
string _where = Regex.Replace(test, @"\ where\ ", " where (", RegexOptions.IgnoreCase | RegexOptions.Compiled);我要得到的结果是 select * from testtable where (id in(select id form table where tid=1)也就是说遇到的第一个where要替换成 where (
应该怎么写那个正则啊?
string _where = Regex.Replace(test, @"\ where\ ", " where (", RegexOptions.IgnoreCase | RegexOptions.Compiled);我要得到的结果是 select * from testtable where (id in(select id form table where tid=1)也就是说遇到的第一个where要替换成 where (
应该怎么写那个正则啊?
void Main()
{
string test = "select * from testtable where id in(select id form table where tid=1)";
Regex reg=new Regex(@"\swhere\s");
string _where = reg.Replace(test," where (", 1);
Console.WriteLine(_where);
//select * from testtable where (id in(select id form table where tid=1)}
void Main()
{
string test = "select * from testtable where id in(select id form table where tid=1)";
Regex reg=new Regex(@"\swhere\s");
string _where = reg.Replace(test,"$0(", 1);
Console.WriteLine(_where);
//select * from testtable where (id in(select id form table where tid=1)}