StreamReader sr = new StreamReader("C:\\Users\\Administrator\\Desktop\\blogbbs\\dd.txt",Encoding.Default); StringBuilder sb = new StringBuilder(); string s = ""; string patt = "【(.+?)】"; Regex r = new Regex(patt); while((s = sr.ReadLine()) != null) { if (r.IsMatch(s)) { Match m = r.Match(s); sb.AppendLine(m.Groups[1].Value); } } File.AppendAllText("C:\\Users\\Administrator\\Desktop\\blogbbs\\123.txt",sb.ToString(),Encoding.Default);
读取txt正则匹配行写入txt,布布扣,bubuko.com
时间: 2024-10-15 12:51:02