日期:2014-05-18  浏览次数:20865 次

C#里正则表达式类Regex的$1,$2,$3在哪里?要怎么用?Replace时要在代替字符串里用$1,$2,$3又该怎么用?
如题。。。。。。。。。。。。。。。。。。。。。。
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

------解决方案--------------------
没太用过$1,我随便写个例子

 string str = "window NT, window CE";
string s = Regex.Replace(str, "^(.*?)(NT)(.*?)(CE)$", "$1$4$3$2");
Console.WriteLine(s); //window CE, window NT
------解决方案--------------------
文件说明看不明白,那就来段代码。
C# code
 
string str = "select * from table a,table b where a.test='-1' and a.test=b.test order by a.test";
str = Regex.Replace(str, @"([\S]+?)='(-1)'", "$1ABC=$2ABCD");