首页 新闻 会员 周边

.net 中替换字符串的问题

0
悬赏园豆:10 [已解决问题] 解决于 2011-10-15 09:22

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 ( 应该怎么写那个正则啊?

华崽崽的主页 华崽崽 | 初学一级 | 园豆:19
提问于:2011-10-14 21:43
< >
分享
最佳答案
0
string test = "select * from testtable where id in(select id form table where tid=1)";
Regex regex = new Regex(" where ", RegexOptions.IgnoreCase);
string _where = regex.Replace(test, " where (", 1);
收获园豆:10
Lionheart Zhang | 菜鸟二级 |园豆:334 | 2011-10-15 00:20
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册