62,046
社区成员
发帖
与我相关
我的任务
分享
class Program
{
static void Main(string[] args)
{
string test = "id=@0 and title='@1' and class=@2";
Regex reg = new Regex(@"(?i)(?<=@)\d+");
string result = reg.Replace(test, delegate(Match m) { return (Convert.ToInt32(m.Value) + 5).ToString(); });
Console.WriteLine(result);
}
/*
* id=@5 and title='@6' and class=@7
*/
}
List<string> list = new List<string> { "id=@0 and title='@1' and class=@2", "name=@9", "username='@19'" };
Regex reg = new Regex(@"(?<=@([']?))\d+(?=\1)");
foreach (string s in list)
{
string result = reg.Replace(s, m => { return (Convert.ToInt32(m.Value) + 5).ToString(); });
File.AppendAllText(@"E:\3.txt", result + "\r\n");
}
/*
id=@5 and title='@6' and class=@7
name=@14
username='@24'
*/