C#正则UrlEncode($2)的该怎么写啊
string str = "1X23Y4";
str = Regex.Replace(str, @"(?<=1)([^2]*)(?=23([^4]*))", "$2");
public static string UrlEncode(string str)
{
StringBuilder sb = new StringBuilder();
return (sb.ToString());
}
我想把所取的值$2换一下编码,写成这个样子,
str = Regex.Replace(str, @"(?<=1)([^2]*)(?=23([^4]*))", UrlEncode("$2"));
这个UrlEncode("$2")该写成什么样子啊?本人菜鸟不要嘲笑。。。
c#
string
------解决方案-------------------- str = Regex.Replace(str, @"(?<=1)([^2]*)(?=23([^4]*))", delegate(Match m)
{
string s = m.Groups[2].Value;
//处理s
return s;
});