using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"Message Timestamp:(?<Time>[^|]+)\|";
string input = @" DT=2018-05-14T01:17:57.805-0700 |TrasID=Hostname1:processName1:201805140116510739:Uniqnumber1 |Type=Response Sent | Severity=INFO ||Main=XXXXXXXXXXXXXXX, Message Timestamp:2018-05-14 01:17:57.641|
Event2
DT=2018-05-14T01:17:57.649-0700 |TrasID=Hostname1:processName1:201805140116510739:Uniqnumber1 |Type=Request Received | Severity=INFO|Main=XXXXXXXXXXXXXXX, Message Timestamp:2018-05-14 01:17:57.641|";
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