代码:
using System.Text.RegularExpressions; namespace GetData { internal class Program { private static void Main(string[] args) { var lines = File.ReadAllLines("data.txt"); Regex re = new Regex("(?<=\").*?(?=\")", RegexOptions.None); var myList = new List<string>(); foreach (var line in lines) { MatchCollection mc = re.Matches(line); foreach (Match m in mc) { myList.Add(m.Value); Console.WriteLine(m.Value); } } File.WriteAllLines("result.txt", myList.ToArray()); Console.WriteLine("---------------------"); Console.ReadKey(); } } }
标签:Regex,Console,双引号,C#,正则表达式,WriteLine,myList,txt,re From: https://www.cnblogs.com/wzwyc/p/16921361.html