using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^(?<date>\d{2}\.\d{2}\.\d{4})\s(?<time>\d{2}:\d{2}:\d{2}\.\d{3})\s{2}(?<msg>.+?(?=\s\d))\s(?<id>.{4})\s(?<name>.+?(?=$|\d{2}\.))(?<comment>.*$)";
string input = @"04.08.2024 06:41:14.775 Получено время 2447 Название устройства №2 04.08.2024 6:41:15 - синхронизация не требуется
04.08.2024 06:43:14.786 Получено время 22B3 Название устройства №3 04.08.2024 6:43:16 - время получения ответа превышает допуск
04.08.2024 11:47:01.967 Истекли попытки отправить запрос 234C Название устройства №4
05.08.2024 14:03:55.149 Получено время 2356 Название устройства №1 05.08.2024 14:03:57 - время получения ответа превышает допуск
05.08.2024 14:03:56.796 Получено время 2356 Название устройства №1 05.08.2024 14:03:58 - требуется синхронизация
05.08.2024 14:03:58.920 Установлена коррекция времени 2356 Название устройства №1";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx