using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?P<time>\d{8}T\d{6}) (?P<rti>.+) (?P<timestamp>\d+)\s?Bus=\s?(?P<bus>.*?)\s?C=\s?0x(?P<cmd>[0-9a-fA-F]{2})\s?S=\s?(?P<status>\w+)\s?RT=\s?(?P<rt>\d+)\s?RDI=\s?0x(?P<rdi>[0-9a-fA-F]{2})\s?EOT=\s?0x(?P<eot>[0-9a-fA-F]{2})\s?Data=\s?(?P<data>([0-9a-fA-F]{2}\s?)*)\s?REPLY=\s?(?P<reply>([0-9a-fA-F]{2}\s?)*)";
string input = @"20141011T042032 - 14362918521340 Bus=PsycheMbusSia2-A C=0xc8 S=RESP RT=08 RDI=0x06 EOT=0x0c Data=84 9f REPLY=4f c0 c0\n
20200515T000132 4 2338257812 Bus=PsycheMbusSia2-A C=0xc8 S=RESP RT=08 RDI=0x1c EOT=0x04 Data= 83 90 88 93 8b 98 88 90 REPLY= 3f
20200515T000132 4 2338257812 Bus=PsycheMbusSia2-A C=0xc8 S=RESP RT=08 RDI=0x1c EOT=0x04 Data=REPLY= 3f
20200515T000140 12 2343757812 Bus=PsycheMbusSia2-A C=0xc8 S=RESP RT=08 RDI=0x03 EOT=0x0C Data= 84 9c REPLY= 4c c0 c0
";
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