小编Dan*_*Dan的帖子

为什么我的Regex.Replace字符串包含两次替换值?

我有以下字符串:aWesdE,我想转换为http://myserver.com/aWesdE.jpg使用Regex.Replace(string, string, string, RegexOptions)

目前,我使用此代码:

string input = "aWesdE";
string match = "(.*)";
string replacement = "http://myserver.com/$1.jpg";
string output = Regex.Replace(input, match, replacement,
          RegexOptions.IgnoreCase | RegexOptions.Singleline);
Run Code Online (Sandbox Code Playgroud)

结果是输出结果如下: http://myserver.com/aWesdE.jpghttp://myserver.com/.jpg

因此,替换值正确显示,然后似乎再次附加 - 非常奇怪.这里发生了什么?

.net c# regex

5
推荐指数
1
解决办法
538
查看次数

标签 统计

.net ×1

c# ×1

regex ×1