需要给文件中1,2,3........106的key找出来+106 .
code 实现如下:
static void Main(string[] args) { //string words = "INSERT [dbo].[ClientApiUrl] ([ClientUrlId], [ClientUrl], [ProtocolType], [RouteType], [MethodType], [ServiceName], [RowCreatedOn], [RowLastModifiedOn], [RowLastModifiedBy]) VALUES (1, N'/Security_v1/api/User/.*$', 1, 1, 1, N'Sensitech.Security_v1/WebAPI', CAST(N'2017-01-17T08:29:01.0366667+00:00' AS DateTimeOffset), CAST(N'2017-01-17T08:29:01.0366667+00:00' AS DateTimeOffset), N'&system')INSERT [dbo].[ClientApiUrl] ([ClientUrlId], [ClientUrl], [ProtocolType], [RouteType], [MethodType], [ServiceName], [RowCreatedOn], [RowLastModifiedOn], [RowLastModifiedBy]) VALUES (2, N'/Security_v1/api/User/.*/.*$', 1, 1, 1, N'Sensitech.Security_v1/WebAPI', CAST(N'2017-01-17T08:29:01.1366667+00:00' AS DateTimeOffset), CAST(N'2017-01-17T08:29:01.1366667+00:00' AS DateTimeOffset), N'&system')"; string filePath = @"D:\ClientApiUrl.txt"; StreamReader reader = new StreamReader(filePath, Encoding.Default); string content = reader.ReadToEnd(); reader.Close(); string pattern = @"(?<=,\s)\d+(?=,)"; Regex r = new Regex(pattern); MatchEvaluator evaluator = new MatchEvaluator(NumberPlus); content = Regex.Replace(content, pattern, evaluator); StreamWriter write = new StreamWriter(filePath,false,Encoding.Default); write.Write(content); write.Close(); Console.ReadKey(); }