using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using io = System.IO; namespace BBWY.Test { internal class Program { static void Main(string[] args) { var rootPath = @"C:\Users\pengcong001\Desktop"; var resultList = new List(); var minDate = 11; var maxDate = 25; rootPath = @"C:\Users\pengcong001\Desktop\test"; for (var i = minDate; i <= maxDate; i++) { var content = io.File.ReadAllText(io.Path.Combine(rootPath, $"2022-05-{i}.txt"), Encoding.UTF8); var matches = Regex.Matches(content, @"""logisticsCompanyName"":\s*""(.+)"","); foreach (Match match in matches) { if (match.Success) { var _1688logisticsCompanyName = match.Groups[1].Value; if (!resultList.Any(s => s.Equals(_1688logisticsCompanyName))) resultList.Add(_1688logisticsCompanyName); } } } Console.WriteLine(resultList.Count()); foreach (var s in resultList) Console.WriteLine(s); Console.ReadKey(); } } }