日期:2014-05-20  浏览次数:20369 次

来个正则高手帮我解决一下,谢谢
字符串 "WHERE ([Name] = @p__linq__0) OR ([Id] > @p__linq__1) OR ([Id] > @p__linq__8)"
正则替换为
"WHERE ([Name] = {0}) OR ([Id] > {1}) OR ([Id] > {8})"


Regex.Replace(s, " ", "")

------解决方案--------------------
C# code

void Main()
{
    string str="WHERE ([Name] = @p__linq__0) OR ([Id] > @p__linq__1) OR ([Id] > @p__linq__8)";
    str=Regex.Replace(str,@"@[^2]+?(\d+)(?=\)|$)","{$1}");
    Console.WriteLine(str);
    //WHERE ([Name] = {0}) OR ([Id] > {1}) OR ([Id] > {8})
}