Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.IO;
- using System.Text;
- using System.Threading.Tasks;
- using System.Text.RegularExpressions;
- namespace REGEXP
- {
- /// <summary>
- /// РЕГУЛЯРНЫЕ ВЫРАЖЕНИЯ ВАРИАНТ 3
- /// </summary>
- class Program
- {
- static string ValidateInputFile()
- {
- string s;
- while (true)
- {
- Console.Write("Введите имя входного файла : ");
- try
- {
- s = Console.ReadLine();
- StreamReader sr = new StreamReader(s);
- Console.WriteLine("Файл найден!");
- break;
- }
- catch (Exception)
- {
- Console.WriteLine("Неверное имя файла или такого файла не существует! Повторите попытку еще раз...");
- }
- }
- return s;
- }
- static void Main(string[] args)
- {
- string inputfilename = ValidateInputFile();
- Console.Write("Введите имя выходного файла : ");
- string outputfilename = Console.ReadLine();
- string pattern = @"[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}";
- using (StreamReader sr = new StreamReader(inputfilename))
- {
- using (StreamWriter sw = new StreamWriter(outputfilename))
- {
- string s;
- while (!sr.EndOfStream)
- {
- s = sr.ReadLine();
- Match M = Regex.Match(s, pattern);
- if (M == Match.Empty)
- {
- sw.WriteLine(s);
- }
- }
- }
- }
- Console.WriteLine("Файл обработан!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement