首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

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

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

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"); 

热点排行